A
/ \ _ Play Now Nemesis on
| | | | _______ _ _ _______ _______ _ _______
| |\ | | | ____| | \ / | | ____| / ____| | | / ____|
/-------/-------------------------------------------------------------------,
O= Home <=XX| About News Pics Adventurers Wizards Download Connect >
\-------\-------------------------------------------------------------------'
| | \ | | |____ | | | | | |____ ___ \ \ | | ___ \ \
| | \_| |_______| |_| |_| |_______| |_______/ |_| |_______/
\ /
V
Documentation Area
Document Path: /doc/lib/format_date
Simul efun: format_date - get a string of date/time as you like it
Synopsis:
mixed format_date(string format, int time)
Description:
Returns the time/date formatted by the format-string or, if no
format-string is given, an array (see below). If no time (in seconds
since 1970-01-01 00:00:00) is given, time() (current time) is used.
The format-string works like a (s)printf() format-string. But valid
interpreted sequences are these:
%% a literal %
%a the abbreviated weekday name (e.g., Wed)
%A the full weekday name (e.g., Wednesday)
%u the weekday number (1-7, where 1 is Monday)
%w the weekday number (0-6, where 0 is Sunday)
%b the abbreviated month name (e.g., Dec)
%B the full month name (e.g., December)
%m the month number (1-12)
%d the day of month (1-31)
%H the hour (0-23)
%I the hour (1-12)
%M the minute (0-59)
%S the second (0-59)
%Y the year (e.g., 2003)
%y last two digits of the year (0-99)
%p AM or PM
%c date and time (e.g., Wed Jan 6 15:32:40 2016)
%R time (same as %02H:%02M)
%T time (same as %02H:%02M:%02S)
%r time (same as %02I:%02M:%02S %p)
%D date (same as %02m/%02d/%02y)
%s seconds since 1970-01-01 00:00:00 UTC (as returned by time())
Of course you can use all (s)printf()-modifiers after the %.
Return value:
with format-string a string, else an array of the form:
({ /* sizeof() == 7 */
<string weekday>, // the abbreviated weekday name
<string month>, // the abbreviated month name
<int day>, // the day of month
<int hour>,
<int minute>,
<int second>,
<int year>
})
Examples:
write(format_date("Weekday: %a\n"+
"Month: %b\n"+
"Day of month: %d\n"+
"Hour: %H\n"+
"Minute: %M\n"+
"Second: %S\n"+
"Year: %Y\n"+
"Full date: %c\n"+
"Time: %T\n"));
Note:
The interpreted sequences are similar to the 'date' command's
format-string on Unix-like systems. More of them might come ...
See also:
This page was generated in LPC
Imprint / Impressum