Jump to content

PHP date() Midnight?


Twango

Recommended Posts

Just wondering, what EXACTLY would the php function date() Return at midnight?Like would it say 12:00 PM, 12:00 AM? Or What?Like if I wanted to test if it was after between 9PM and 12PM (Midnight) What would I do? Thanks.Or should I just use 24 hr time?Thanks.P.S. what would 1AM and 12:01 PM be in PHP 24 hr time? the way w3schools formatted it was freaky.

Link to comment
Share on other sites

You tell the date function what to output, there is no default format. The date function takes a format string, and an optional timestamp. The format string is required, and it can be whatever format you want to build from the format characters you see on the manual page for the date function.If you want to test, you can use mktime to create a timestamp for any time you want, then experiment displaying it with the date function.

Link to comment
Share on other sites

Well, g gives a number between 1 and 12, without leading zeros, and i gives a number between 0 and 59, with leading zeros.You know, you can always just create a timestamp for midnight and noon and test this. You can use mktime to create a timestamp.It will probably also be helpful for you to review the list of format characters:http://www.php.net/manual/en/function.date.phpObviously I'm trying to make the point that you can easily determine the answers to questions like this yourself, you don't need to ask someone else and wait for an answer for basic things like this.

Link to comment
Share on other sites

Midnight is at 12:00 AM and noon is at 12:00 PM.PHP will display "am" or "pm" using "a" in the format string, or "A" for uppercase.

date('g:i a'); // Outputs something like "2:45 pm"date('g:i A'); // Outputs something like "2:45 PM"

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...