date()
string date (string $format [, int $timestamp = time() ] )
Description
date() returns a string formatted according to the given integer timestamp or the current time from the RTC if no timestamp is given. In other words, $timestamp is optional and defaults to the value of time().
※ available F/W version : all
Parameters
- $format
Y - A full numeric representation of a year, 4 digits (example: 2015)
y - A two digit representation of a year (example: 15)
M - A short texture representation of a month, three letters (example: Mar)
m - Numeric representation of a month with leading zeros (example: 03)
n - Numeric representation of a month without leading zeros (example: 3)
d - Day of the month, 2 digits with leading zeros (01 to 31)
j - Day of the month without leading zeros (1 to 31)
D - A textual representation of a day , three letters (example: Mon)
g - 12-hour format of an hour without leading zeros (1 to 12)
G - 24-hour format of an hour without leading zeros (0 to 23)
h - 12-hour format of an hour with leading zeros (01 to 12)
H - 24-hour format of an hour with leading zeros (00 to 23)
i - Minutes with leading zeros (00 to 59)
s - Seconds with leading zeros (00 to 59)
a - Lowercase Ante meridiem and Post meridiem (am or pm)
A - Uppercase Ante meridiem and Post meridiem (AM or PM)
- $timestamp - the optional integer Unix timestamp. The default value is the current time from the RTC if this parameter is omitted.
Return values
Returns a formatted string of current system time.
Example
<?php
$str = date("Y:M-d-TH:i:s");
echo "$str\r\n"; // OUTPUT: 2015:Mar-16-T16:27:35
while(1);
?>
See also
mktime() / time()
Remarks
This function is identical to the PHP group’s date() function.
However, it supports only 16 types of arguments.