Syntax: formattimestring(str format, int time)
Returns a string with the formatted time.


formattimestring takes the given input time (relative to timevar2) and formats it against the given input format. The input format takes input like the strftime function in some other languages.

The markers in the format are substituted with the correct time values and the entire formatted time is returned. All markers are one letter with a preceding percent sign (i.e. %H). Anything that is given in the input format that does not follow this format is treated as a literal and ignored. Literals will, however, be returned in the result. For instance, %H:%M will return a value like 00:00 including the literal : character.

Some of the supported conversion markers are listed as follows:

%aAbbreviated weekday name (like Mon)
%AFull weekday name (like Monday)
%bAbbreviated month name (like Jan)
%BFull month name (like January)
%CCentury number represented as two digit number
%dDay of the month represented as a number (from 01 to 31)
%HHour represented as a decimal number using a 24-hour clock (from 0 to 23)
%IHour represented as a decimal number using a 12-hour clock (from 1 to 12)
%jDay of the year represented as a number
%mMonth of the year represented as a number
%MMinute of the hour represented as a number
%pEither AM or PM (midnight is AM and midday is PM)
%SSeconds of the minute represented as a number
%uDay of the week represented as a number (from 1 to 7 where Monday is 1)
%UWeek of the year represented as a number (from 1 to 53)
%wDay of the week represented as a number (from 0 to 6 where Monday is 0)
%yYear represented as a number without the century (from 00 to 99)
%YYear represented as a number including the century
%zTimezone as offset from GMT

The full list is available in the Linux Manual (man strftime).


You can use formattimestring as follows:

function onCreated()
  echo(formattimestring("%d/%M/%Y %H:%M", 1276989159));

… which would echo "19/12/2010 23:12" (bearing in mind that 1276989159 was the value of timevar2 at the given time).

function onCreated()
  echo(formattimestring("%d/%M/%Y %H:%M", timevar2));

… would output the current date and time in the same format as the above example.



There is one comment on this page. [Display comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki