skaterdav85 Posted August 24, 2010 Share Posted August 24, 2010 I hate working with times, so I've decided to just learn the details of the date function and create a class that will return all the different formats of times that I could possibly use. However, I have tried the following: date('g:i a', '2010-08-23 16:41:36'); and it returns this notice:Notice: A non well formed numeric value encountered in /Applications/MAMP/htdocs/ on line 16Anyone know why? Or if you know of any good time classes out there, feel free to share! =) Link to comment Share on other sites More sharing options...
dsonesuk Posted August 24, 2010 Share Posted August 24, 2010 you have to provide a timestamp value, use mktime to turn specific date/time into timestampecho mktime(16,41,36,8,23,2010)."<br />"; // equals 1282581696then use it within date() functionecho(date("g:i a", mktime(16,41,36,8,23,2010))."<br />");if you require current date/time, just leave it out, and just leave the format you requireecho(date("g:i a")."<br />");all formatting values are shown herehttp://www.w3schools.com/php/func_date_date.asp Link to comment Share on other sites More sharing options...
End User Posted August 24, 2010 Share Posted August 24, 2010 However, I have tried the following:date('g:i a', '2010-08-23 16:41:36'); I think you want strtotime() in there, for example:date('g:i a', strtotime('2010-08-23 16:41:36')); strtotime() reads almost any date formatted string and returns a timestamp that you can then use in the 2nd argument of date(). I often use it to convert mySQL timestamps to "friendly" dates:$eventstart = "2010-04-01 18:30";$eventstart = date("F d, Y g:i:sa", strtotime($eventstart));"2010-04-01 18:30" converts to "April 01, 2010 6:30:00pm" Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.