Jump to content

Question about storing Date in MYSQL


hammerklavier

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']);

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.