$date = "Aug 31 2010 9:21AM"; Can someone kindly explain how to convert to $newdate = "2010-08-31"; // yyyy-mm-dd
Use string to time function: $date = "Aug 31 2010 9:21AM"; $timestamp = strtotime($date); $newdate = date('Y-m-d',$timestamp); PHP:
Just curious $date = "Aug 31 2010 9:21AM"; $timestamp = strtotime($date); $newdate = date('Y-m-d',$timestamp); Lets say you wanted $newdate to be $newdate = 2010-08-30 -1 day Is there quick way to do this?
The usage is self explanatory date($format, $timestamp); where $format is how its formatted - refer to the date function page for all the possible format characters.
Just subtract the day (in timestamp) from the timestamp. Every day is 24 hours * 60 minutes * 60 seconds = 86400 $newdate = date('Y-m-d',$timestamp-86400); PHP: