Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Display The Current Date/time, With a simple PHP code
Unholy Prayer
post 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.
Go to the top of the page
 
+Quote Post
Johnny
post 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
T17 GFX Crew



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.
Go to the top of the page
 
+Quote Post
fffanatics
post 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.
Go to the top of the page
 
+Quote Post
Blessed
post 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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How do you test your php code(77)
  2. Php Clock(7)
  3. Change Permission With Php Code(3)
  4. Adapting Html Code Embed To Work On Phpnuke(7)
  5. Dynamic Image / Signature Generator(12)
  6. Wap Source Code Viewer(4)
  7. My Code Doesnt Resize Large Images, Please Help.(2)
  8. Php Education Class (first Code)(0)
  9. How To Display The Latest Forum Post On Main Page(4)
  10. How To Make A Random 7 Number Code?(2)
  11. Php Date() Problem [resolved](4)
  12. Whats Wrong>?(9)
  13. Awesome Source Code Viewer Script(7)
  14. Html Code Tester. Online Script(15)
  15. Displaying Date And Time (gmt+8)(5)
  1. I Need Some Proof Reading For My Code Please! [resolved](7)
  2. Will This Code Work(5)
  3. Use Rss In Php Code(3)
  4. Php Code(15)
  5. How To Display Images Of A Directory(4)
  6. Php Code Needed(5)
  7. Php Code?(12)
  8. Php Code Needed Iii(10)
  9. Php Date()?(4)
  10. Php And Mysql Programming(2)
  11. Malicious Code Injection(3)
  12. Php Source Code Unveiled In Browser?(7)
  13. Create Table - Mysql Code - Help(1)


 



- Lo-Fi Version Time is now: 8th September 2008 - 05:12 AM