Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-81074

core_date::strftime may give unexpected results

XMLWordPrintable

      If you pass a timestamp as a string (which is how it would come out of the DB) instead of an int, you get different results:

      core_date::strftime('%c', '1708405742'); --> 28 February 5742 at 5:08 pm
      core_date::strftime('%c', 1708405742);   --> 20 February 2024 at 5:09 am

      While depricated in 8.1 and up, strftime gives a very different (and more expected) result:

      strftime('%c', '1708405742'); --> Tue 20 Feb 05:09:02 2024
      strftime('%c', 1708405742);   --> Tue 20 Feb 05:09:02 2024 

      I also just noticed the format is different, but I was mostly concerned about the actual date/time being parsed incorrect.

      I know this is barely used in core (I think date_format_string() is the only thing that directly uses it), and there is a separate ticket to depreciate strftime (MDL-77366) in core completely, but I figured I should at least raise this for others who might run across it.

            lucaboesch Luca Bösch
            emerrill Eric Merrill
            Paul Holden Paul Holden
            Safat Shahin Safat Shahin
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour, 23 minutes
                1d 1h 23m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.