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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.