Re: converting seconds since unix epoc to date array

From: Date: Tue, 07 Sep 2004 04:13:34 +0000
Subject: Re: converting seconds since unix epoc to date array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-196013@lists.php.net to get a copy of this message
Jason FB wrote:
Can anyone tell me how to convert a date stored in the format "YYYY-MM-DD" to an integer of seconds since unix epoc, then add $daysToAdd days to this value (I suppose if the integer was a number of seconds it would have to be $daysToAdd*60*60*24 to get the number of seconds to add) then convert the new value to a timestamp which I can output using the function string date ( string format [, int timestamp])
Is this a MySQL timestamp? If so, you can use TO_UNIXTIME() in your query to return a Unix timestamp instead of a MySQL one. You can use DATE_ADD() to add days to the timestamp. You can also use DATE_FORMAT() to format the timestamp before it's returned also. If you don't want to do that, what's wrong with strtotime('YYYY-MM-DD') to get the unix timestamp? -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#196013) next »