Jump to content

Date Conversion


adamwhiles

Recommended Posts

I have a field in my database that holds a date like so: 2006-06-23

I want to convert that with php so I can print it out like this: June 23, 2006

I need to keep the format of the date in the table because it needs to be 2006-06-23 due to another script that uses the date in that format.

So how can i use PHP to pull the date out of the database and convert it to the longer format?
Link to comment
Share on other sites

easy:

[code]
$oldDate = '2006-06-23';
$answer = date('F d, Y',strtotime(date('Y-m-d',$oldDate)));
[/code]

so ur taking the old date, converting it to a unix timestamp, then reformatting it to how you want to see it.

FYI - it's easier just to start out with the Unix timestamp in the DB. =D
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.