The following functions are available:
- now : returns the current timestamp in the Templeet format
- timestamp2day , timestamp2month , timestamp2year , timestamp2hhmm and timestamp2hhmmss : timestamp handling
- format_timestamp : format of a Templeet timestamp
- format_unixtimestamp : format an UNIX timestamp
now
now returns the local date and time with the YYYYMMDDhhmmss format, 4 digits for years, 2 digits for months, 2 digits for days, 2 digits for hours, minutes and seconds. (e.g. 20020814203015 for the 14th August 2002 at 20:30:15). There is no parameter.
Exemple :
~now() => 20080512234636
The timestamp2 functions
There is 5 functions to extract part of a date with a YYYYMMDDhhmmss or the ISO format YYYY-MM-DD hh:mm:ss.
They are:
- ~timestamp2day
- ~timestamp2month
- ~timestamp2year
- ~timestamp2hhmm
- ~timestamp2hhmmss
The only parameter is the date to convert.
Exemples :
~timestamp2month('20080512234636') => 05
~timestamp2hhmmss('20080512234636') => 23:46:36
~timestamp2year('20080512234636') => 2008
format_timestamp
~format_timestamp() takes two parameters. The first one is the destination format, the second is the date (again in the YYYYMMDDhhmmss or YYYY-MM-DD hh:mm:ss format).
~format_timestamp('%d/%m/%y %H:%M','20080512234636')
This function results in : 12/05/08 23:46
The following characters are used for specifying the output format :
%a - short name of the week day (local).%A - long name of the week day (local).
%b - short name of the month (local).
%B - long name of the month (local).
%c - prefered representation for dates and times (local).
%C - century number (the year divided by 100 and rounded between 0 and 99)
%d - day of the month with a leading zero. (between 01 and 31)
%D - similar to %m/%d/%y
%e - day of the month with a leading space. (between ' 1' and '31')
%h - similar to %b
%H - hour with leading zeros in 24-hours format. (between 00 and 23)
%I - hour with leading zeros in 12-hours format. (between 01 and 12)
%j - day of the year with leading zeros. (between 001 and 366)
%m - month in numeric (from 1 to 12)
%M - minute in numeric
%n - newline character
%p - either `am' or `pm' depending on the absolute time or the local format.
%r - hours with a trailing 'a.m.' or 'p.m.'
%R - hour in a 24-hours format.
%S - seconds in numeric.
%t - tab character.
%T - current time (similar to %H:%M:%S).
%u - number of day in the week, between 1 and 7, 1 being monday.
%U - week number within the year, with the first sunday of the year as the first day of the first week of the year.
%V - week number as defined by ISO 8601:1988, in numeric, between 01 and 53. The week 1 is the first week having more than 4 days in the year, and having monday as the first day.
%W - week number within the year, but with the first monday of this year being the first day of the first week.
%w - day of the week in numeric, but with 0 for sunday.
%x - prefered format for date without hours.
%X - prefered format for time without date.
%y - year in two digit, with leading zeros.
%Y - year in four digits with leading zeros.
%Z - timezone, name or abbreviated.
%% - a '%' character.
format_unixtimestamp
UNIX timestamp are also widespread. It is the number of seconds elapsed since the 1st January 1970 00:00:00 GMT. For instance 09/09/01 at 03:46:40 was the UNIX timestamp 1000000000.
The use of ~format_unixtimestamp() is exactly the same than ~format_timestamp()
~format_unixtimestamp('%d/%m/%y %H:%M:%S', 1210628796)
The previous example returns "12/05/08 23:46:36".
Download
FAQ