Re: [PHP-DB] I`m having a little trouble displaying future dates... From: Chris Adams (chris <email protected>)
Date: 10/11/00

> But it only stores as 0000-00-00 00:00:00. I suppose it has something to
do
> with my format.

First, I'd recommend ditching the manual date formatting and using Unix
timestamps (see date()/time() in the PHP manual and the MySQL UNIX_TIMESTAMP
/ FROM_UNIX_TIME functions). Among other things, this makes it very easy to
add times and eliminates the need to spend time worrying about date formats
in your code (on the code I write, Unix timestamps are used everywhere for
storage and calculations; the only place I worry about formats is in the
date() call to display something to the user). It also allows you to things
like $tomorrow = time() + 86400, since you're just manipulating seconds.

On the content management system I wrote, I gave the users 6 fields for the
release date of an article (year / month / day, hour / minute / second),
which sidesteps the whole issue you're experiencing. Alternately, you could
just correct the date using something like

//$ar_timestamp has the user-selected date for the article

$gd = getdate($ar_timestamp);
// Correct to 7AM that day
$corrected_timestamp = mktime(7,0,0,$gd['mon'],$gd['mday'],$gr['year']);

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>