Jump to content

Date Format help


Skipjackrick

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/193369-date-format-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/193369-date-format-help/#findComment-1018096
Share on other sites

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"

?>

Link to comment
https://forums.phpfreaks.com/topic/193369-date-format-help/#findComment-1018102
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.