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

Date handling can't cope with UTC higher than 12 eg UTC +14 (Pacific/Kiritimati)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3.9, 2.4.6, 2.5
    • Fix Version/s: None
    • Component/s: Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE

      Description

      All date handling in moodlelib.php assumes a timezone > 13

      These functions are ones I found that need fixing:
      usergetdate(), date_format_string(), make_timestamp(), usertimezone(), usertime()

      1.9 codebase example from reporter (but this is still an issue in 2.x)

      $usertime = userdate(gmmktime(), get_string('strftimedaydatetime'), "Pacific/Kiritimati" );

      echo $usertime yields: "09/10 22:48"

      When I use the below code, the time is correctly displayed:

      $userDateTime = new DateTime(null, new DateTimeZone("Pacific/Kiritimati"));
      $usertime = $userDateTime->format('m/d H:i');

      echo $usertime yields: "09/10 16:48"

      More discussion on this here:
      https://moodle.org/mod/forum/discuss.php?d=237545

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jlukar John Lukar
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: