Re: converting seconds since unix epoc to date array
| From: | Jason Davidson | Date: | Tue, 07 Sep 2004 05:51:40 +0000 |
| Subject: | Re: converting seconds since unix epoc to date array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-196015@lists.php.net to get a copy of this message | ||
How is the date stored, MySQL db??? if so, you can select dates out as
unix timestamps. Otherwise i would use mktime or strtotime...
Jason
Jason FB <jasonfb@earthlink.net> 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])
>
> I tried doing this with mktime() and couple different ways using
> strtotime() and also with strftime() but I kept getting -1 as the
> result for strtotime() indicating the function couldn't interpret the
> given date.
>
> I've been through all the date-related functions in the manual I can
> think of, but I'm stumpped on this one...