Jump to content

Output date and time from database


merylvingien

Recommended Posts

Hi Fellas, having a bit of trouble getting the date and time to display correctly from database.

 

At the moment i have the date stored in the database as "datetime" and as an example it stores the date as "2010-01-19 17:01:11"

 

I want to output this on the page as  Tuesday 19 2010 @ 17:01 PM

 

But whatever i try it isnt having it.

 

Ive tried numerous things and googled lots, but i think my brain is fried now, and a little help would good.

Link to comment
Share on other sites

You can use strtotime to convert your mysql timestamp into a unix timestamp. Using the unix timstamp you can pass this into the secound parameter for the date function to reformatted your date. Example

 

$mysqlTimestamp = '2010-01-19 17:01:11';

$unixTimestamp = strtotime($mysqlTimestamp);

echo date('l jS Y h:i:s a', $unixTimestamp);

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.