Monday, August 27, 2012

Converting a Time Stamp with date

Converting a Time Stamp with date():

The date() function returns a formatted string representing a date. You can exercise an enormous amount of control over the format that date() returns with a string argument that you must pass to it.
date(format,timestamp)
The date() optionally accepts a time stamp if ommited then current date and time will be used. Any other data you include in the format string passed to date() will be included in the return value.
Following table lists the codes that a format string can contain:
FormatDescriptionExample
a'am' or 'pm' lowercasepm
A'AM' or 'PM' uppercasePM
dDay of month, a number with leading zeroes20
DDay of week (three letters)Thu
FMonth nameJanuary
hHour (12-hour format - leading zeroes)12
HHour (24-hour format - leading zeroes)22
gHour (12-hour format - no leading zeroes)12
GHour (24-hour format - no leading zeroes)22
iMinutes ( 0 - 59 )23
jDay of the month (no leading zeroes20
l (Lower 'L')Day of the weekThursday
LLeap year ('1' for yes, '0' for no)1
mMonth of year (number - leading zeroes)1
MMonth of year (three letters)Jan
rThe RFC 2822 formatted dateThu, 21 Dec 2000 16:01:07 +0200
nMonth of year (number - no leading zeroes)2
sSeconds of hour20
UTime stamp948372444
yYear (two digits)06
YYear (four digits)2006
zDay of year (0 - 365)206
ZOffset in seconds from GMT+5

Example:

Try out following example
<?php
print date("m/d/y G.i:s<br>", time());
print "Today is ";
print date("j of F Y, \a\\t g.i a", time());
?>
It will produce following result:
01/20/00 13.27:55
Today is 20 of January 2000, at 1.27 pm

No comments:

Post a Comment

Labels

AJAX (1) Answers (1) Apache (1) Array (16) bug (1) C (1) C++ (1) Calendar (1) Class (1) Commands (1) Cookies (2) Database (2) Date (7) Days (1) explode (1) File Upload (1) FILES (1) firewall (1) fix (1) Functions (26) GET (1) GMT (1) JavaScript (2) localhost (1) Mail (1) Menu (1) MYSQL (13) PERL (1) PHP (36) php.ini (1) POST (1) preg_match (1) Questions (1) Script (1) SMS (2) Solution (1) String (1) Time (5) Time Zone (1) Vista (1) Wamp Server (1) windows 7 (2) XML (1)

Popular Posts

Popular Posts