Re: how to use MYSQL date type string in php?

From: Date: Thu, 20 Sep 2001 04:39:04 +0000
Subject: Re: how to use MYSQL date type string in php?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67936@lists.php.net to get a copy of this message
> hi, I 'm new developer in php > I always need to get the date or time from mysql ,and dead it in php,but I > found it defficult to deal mysql date type string in php. mysql date type > string always like "yyyy-mm-dd",in php4.06 I can use strtotime fuction > convert it to unixtimestamp,but in php4.0 ,strtotime des not work.I don't > know why? > And I want to know about how to deal date type string (speciall like > "yyyy-mm-dd") in php , and how to add days in date type string and so > on.Could you introduce me some good code sample or good link about deal > datetime in php. MySQL can do this work for you. ie. select UNIX_TIMESTAMP(column_name) from table ... There are also ways to add intervals and many other things directly in MySQL. However once you have it converted to a unix timestamp doing date-math in PHP is trivial in that you just add the appropriate number of seconds to the timestamp. Lots of info in the MySQL docs on this. -Rasmus

« previous php.general (#67936) next »