return $calendartype->timestamp_to_date_string($date, $format, $timezone, $fixday, $fixhour);
}
+/**
+ * Returns a html "time" tag with both the exact user date with timezone information
+ * as a datetime attribute in the W3C format, and the user readable date and time as text.
+ *
+ * @package core
+ * @category time
+ * @param int $date the timestamp in UTC, as obtained from the database.
+ * @param string $format strftime format. You should probably get this using
+ * get_string('strftime...', 'langconfig');
+ * @param int|float|string $timezone by default, uses the user's time zone. if numeric and
+ * not 99 then daylight saving will not be added.
+ * {@link http://docs.moodle.org/dev/Time_API#Timezone}
+ * @param bool $fixday If true (default) then the leading zero from %d is removed.
+ * If false then the leading zero is maintained.
+ * @param bool $fixhour If true (default) then the leading zero from %I is removed.
+ * @return string the formatted date/time.
+ */
+function userdate_htmltime($date, $format = '', $timezone = 99, $fixday = true, $fixhour = true) {
+ $userdatestr = userdate($date, $format, $timezone, $fixday, $fixhour);
+ if (CLI_SCRIPT && !PHPUNIT_TEST) {
+ return $userdatestr;
+ }
+ $machinedate = new DateTime();
+ $machinedate->setTimestamp(intval($date));
+ $machinedate->setTimezone(core_date::get_user_timezone_object());
+
+ return html_writer::tag('time', $userdatestr, ['datetime' => $machinedate->format(DateTime::W3C)]);
+}
+
/**
* Returns a formatted date ensuring it is UTF-8.
*