Jump to content

Recommended Posts

What is the best way to store dates into database so the data can be retrieved later on.

 

For example:

 

I use this to get the date and i store it.

<?php
$date = date('d/m/y');
?>

However, if i wanted it to say '20 March 2007' would this be easy or is there a better way to store them.

 

Cheers,

 

~ Chocopi

Link to comment
https://forums.phpfreaks.com/topic/52234-dates-in-database-retrieving/
Share on other sites

well i use TIME(); but everyone has their own way!

 

<?php
$nextWeek = time() + (7 * 24 * 60 * 60);
                   // 7 days; 24 hours; 60 mins; 60secs
echo 'Now:       '. date('Y-m-d') ."\n";
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";
// or using strtotime():
echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n";
?> 

Cheers for that ::)

 

Anyways, can you help with an array so when i have 20/05/2007 it says 20 May 2007

 

would it be like:

 

<?php
$month = array('','January','February','March','April','May','June','July','August','September','October','November','December');

	while($row = mysql_fetch_assoc($date))
		{
			$mon = $month[$row['date']];
		echo "The month is $mon\n";
		}
?>

Guest
This topic is now 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.