Jump to content

What Time Is It?


phpretard

Recommended Posts

That code, as it's written, could not product that output.

 

<?php
$t=time();
echo($t . "<br />");
echo(date("D F d Y",$t));
?>

would produce something like

1211259067
Tue May 20 2008

The first number "1211259067" is the UNIX timestamp of "right now". The string is that time stamp turned into something readable.

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/106413-what-time-is-it/#findComment-545439
Share on other sites

Time has it's own letters and such...

 

a= Lowercase Ante meridiem and Post meridiem(am or pm)

A= Uppercase Ante meridiem and Post meridiem(AM or PM)

g= 12-hour format of an hour without leading zeros(1 through 12)

G= 24-hour format of an hour without leading zeros(0 through 23)

h= 12-hour format of an hour with leading zeros(01 through 12)

H= 24-hour format of an hour with leading zeros(00 through 23)

i= Minutes with leading zeros(00 to 59)

s= Seconds, with leading zeros(00 through 59)

u= Milliseconds (added in PHP 5.2.2)  Example: 54321

 

To write this:

date('h:i:s A') = 03:12:46 PM

 

You get the idea. Hope this helped!

Link to comment
https://forums.phpfreaks.com/topic/106413-what-time-is-it/#findComment-545444
Share on other sites

I think you should read this page:

 

http://us.php.net/date

 

On that page it shows some examples a little down the page. To print the date and time, you could do something like this:

 

echo date('l jS \of F Y h:i:s A'); = Monday 8th of August 2005 03:12:46 PM

 

^From the link above. You can move around the letters to have it appear as you want.

Link to comment
https://forums.phpfreaks.com/topic/106413-what-time-is-it/#findComment-545450
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.