Jump to content

Recommended Posts

 

Question:

 

I want to store a date such as "Monday January 26, 2009"

 

I echo it in php with $today = date("l F j, Y");

 

Now how do I store it on MySQL ? Do I use a DATE field ? I guess not because it would be 0000-00-00 how do I save the Day too?

 

I have

 

$sql = "insert into table_times (idname, starttime, workdate) values ('$idname', '$starttime', '$today')";

 

where workdate is a DATE field

 

And to retrive date from it back do I access to it with $example =mysql_fetch_array() ;

 

echo $example['workdate'];

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/142530-question-about-storing-date-in-mysql/
Share on other sites

IMA store the date as a DATE field then when i want to view it i format it on the output.. you can store it pre-formatted but your kick yourself when you start to have problems..

 

output is just as easy

$today = date("l F j, Y",$row['workdate']);

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.