Skipjackrick Posted February 25, 2010 Share Posted February 25, 2010 I've got a script that outputs the date and time as: 1998:03:20 00:10:00 I want to break apart that format into something like this <?php $month = 03; //get the month from the formatted date above $day = 20; //get the day from the formatted date above $year = 1998; //get the year from the formatted date above echo "You took that picture on $month / $day / $year"; ?> How do I do that? Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 25, 2010 Share Posted February 25, 2010 Are you able to alter your sql query? Best way to do it would be to convert it from datetime to date when you retrieve your database information. If this isn't an option, we could easily take it and run a little code to pull the values out of the string. Just let me know which way you would rather do it. Quote Link to comment Share on other sites More sharing options...
Skipjackrick Posted February 25, 2010 Author Share Posted February 25, 2010 Are you able to alter your sql query? Best way to do it would be to convert it from datetime to date when you retrieve your database information. If this isn't an option, we could easily take it and run a little code to pull the values out of the string. Just let me know which way you would rather do it. I can't alter that format. It comes from the camera exif data. However, I can do this... <?php $date = '1998:03:20 00:10:00'; $dateval = strtotime($date); //this will output "890377200" ?> Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 25, 2010 Share Posted February 25, 2010 This will give you your three values by themselves: $date = '1998:03:20 00:10:00'; $date = explode(" ", $date); $date = explode(":", $date[0]); echo "$date[0] $date[1] $date[2]" Quote Link to comment Share on other sites More sharing options...
Skipjackrick Posted February 25, 2010 Author Share Posted February 25, 2010 Thanks for the help! Works awesome Quote Link to comment 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.