|
|
|
|
![]() ![]() |
Apr 1 2007, 10:56 PM
Post
#1
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 36 Joined: 27-December 05 Member No.: 16,252 |
Use this code to display the current date and time.
CODE <?php $date = date('l dS \of F Y h:i:s A'); echo "$date"; ?> "l" would display the current day of the week such as Sunday. d displays the day of the month... such as 1 and S adds the appropriate suffix(st). /of simply displays the word "of". F displays the current month with no abbreviations while Y displays the four digit year(2007). "h" displays the current hour with leading zeros if necessary(Ex. 06 for 6 o'clock). "i" displays the minute of the hour with leading zeros if necessary. "s" displays the seconds with leading zeros if necessary and finally "A" displays if it is AM or PM in uppercase format. For a full list of time formats and explanations, visit PHP.net. Hope this is useful for you guys. |
|
|
|
Apr 1 2007, 11:08 PM
Post
#2
|
|
|
[::Boy Wonder::] ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,098 Joined: 5-April 05 From: Costa Mesa, CA Member No.: 5,294 ![]() |
Topic approved, but please read the rules before posting. Tutorials need to be approved by a staff member before they're visible to normal members, so please don't keep reposting if it doesn't show up right away.
|
|
|
|
Apr 2 2007, 06:51 PM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 937 Joined: 14-April 05 From: West Chester, PA Member No.: 5,636 |
Keep in mind that the time and date that this shows will be the time and date on the server so if you are living around the server it will be the same but the actual time may differ from place to place due to timezones, etc.
|
|
|
|
Apr 4 2007, 04:33 PM
Post
#4
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 144 Joined: 22-March 07 Member No.: 40,472 |
i found this on BioRust
CODE - A = Uppercase 12hr time syntax eg. PM
- a = Lowercase 12hr time syntax eg. pm - D = Day eg. Fri - d = Day eg. 03 - F = Full Text Month eg. January - G = Hours in 24 hour format without leading zeros eg. 17 - g = Hours in 12 hour format without leading zeros eg. 7 - H = Hours in 24 hour format with leading zeros eg. 17 - h = Hours in 12 hour format with leading zeros eg. 07 - i = Minutes eg. 29 - M = Month eg. Jan - m = Month eg. 01 - O = GMT time difference in hours eg. +0400 - S = Day of month suffix eg. st, nd, rd, or th. - s = Seconds eg. 28 - T = Timezone setting eg. GMT, PST, EST, etc - t = Total number of days in the month eg. 28, 31, etc. - U = Seconds since the UNIX epoch eg. 1041604168 - W = Week number in year eg. 42 (42nd week in the year) - w = numeric representation of the day eg. 1 = monday, 2 = tuesday, etc. - Y = Year eg. 2003 - y = Year eg. 03 - z = Day of the year eg. 002 A Few Examples To finish this tutorial there now follows a few examples of standard date/time strings and the values they output. I hope you enjoyed this tutorial and good luck with PHP!;) Date String Example Output date("F j, Y, g:i a"); - March 10, 2001, 5:16 pm date("m.d.y"); - 03.10.01 date("j, n, Y") - 10, 3, 2001 date("D M j G:i:s T Y"); - Sat Mar 10 15:16:08 PST 2001 date("H:i:s"); - 17:16:17 date('\i\t \i\s \t\h\e jS \d\a\y.'); - It is the 10th day. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 8th September 2008 - 05:12 AM |