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

custom profile field of type datetime is shown as integer when viewing user profile

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Deferred
    • Affects Version/s: 3.9.1
    • Fix Version/s: None
    • Component/s: User management
    • Labels:
      None
    • Affected Branches:
      MOODLE_39_STABLE

      Description

      /user/profile.php?id=XX

      if the user profile has a custom profile field of type datetime, and has a valid date value, on re-editing the profile the date value is shown, correctly formatted (eg 22 May 1956) but when the profile is simply viewed it is shown as an integer (-429584400).

       

      Although my fix is non-ideal, crude even (date format is hardcoded, no account of time, no account of language or calendar) it works for me now (dates of birth).

      user/profile/lib.php

      function profile_get_user_fields_with_data($userid)

      570 foreach ($fields as $field) {

      571 require_once($CFG->dirroot . '/user/profile/field/' . $field->datatype . '/field.class.php');  

      +572 /* GSP */
      +573 if($field->datatype == 'datetime' && $field->data != '')

      { $field->data = date("j F Y", $field->data); }

       

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            gary.prosser Gary Prosser
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: