patsfans Posted May 27, 2010 Share Posted May 27, 2010 (I think my post got moved because I didn't explain what I needed properly - so sorry mods if this seems like a duplicate) I need to change a date to a timestamp format using a PHP function. I need to take this: $date = "August 18, 2002"; and then using php convert it to this automatically: $newdate = "2002-08-18 00:00:00"; I've looked here: http://www.php.net/manual/en/function.strptime.php but it shows how to do the reverse of what I need. Does anyone know how the correct PHP function to output it that way? Quote Link to comment https://forums.phpfreaks.com/topic/203132-php-changing-date-to-timestamp-format/ Share on other sites More sharing options...
jdavidbakr Posted May 27, 2010 Share Posted May 27, 2010 Perhaps: $newdate = date("Y-m-d H:i:s",strtotime($date)); Quote Link to comment https://forums.phpfreaks.com/topic/203132-php-changing-date-to-timestamp-format/#findComment-1064321 Share on other sites More sharing options...
patsfans Posted May 27, 2010 Author Share Posted May 27, 2010 Perhaps: $newdate = date("Y-m-d H:i:s",strtotime($date)); That is EXACTLY what I needed Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/203132-php-changing-date-to-timestamp-format/#findComment-1064324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.