|
Template:MindTouch > Controls > DateTime
DateTimeTable of contentsNo headers/*** USAGE: DateTime(date, format, timezone) PARAMETERS: date : str Date string to parse, in standard GMT format, i.e. "Thu, 03 Feb 2000 04:15:00 GMT" (optional) format : str (default: 'date') Format string to use, one of 'date', 'datetime' or 'time' date => Jun 1, 2010 datetime => Jun 1, 2010 7:35 PM time => 7:35 PM (optional) timezone : str (default: user.timezone) Timezone to use to render time VERSIONS: 1.0 2-Jun-10 kalida initial version ***/ var dateStr = $0 ?? $date; var format = string.tolower($1 ?? $format ?? 'date'); var timezone = $2 ?? $timezone ?? user.timezone; if (#dateStr > 0) { let dateStr = date.changetimezone(dateStr, timezone); switch (format) { case 'date': date.format(dateStr, 'MMM d, yyyy'); break; case 'datetime': date.format(dateStr, 'MMM d, yyyy h:mm tt'); break; case 'time': date.format(dateStr, 'h:mm tt'); break; } } else { <span class="error-dekiscript">'Error: empty date provided'</span>; } |