Twango Posted August 22, 2011 Share Posted August 22, 2011 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 More sharing options...
justsomeguy Posted August 22, 2011 Share Posted August 22, 2011 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 More sharing options...
Twango Posted August 23, 2011 Author Share Posted August 23, 2011 Ugh, I didn't think I needed to be this Specific, what exactly would date("g:i")Return at MIDNIGHT and NOON? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 23, 2011 Share Posted August 23, 2011 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 More sharing options...
Twango Posted August 23, 2011 Author Share Posted August 23, 2011 Ugh... can't you just tell me, I dont really understand what you mean. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 23, 2011 Share Posted August 23, 2011 Which part don't you understand? Link to comment Share on other sites More sharing options...
Ingolme Posted August 24, 2011 Share Posted August 24, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.