beware of dates before 1969. Justin French <[EMAIL PROTECTED]> wrote: > > Jason, > > This seems to work fine for me: > > <? > $daysToAdd = 5; > $secondsToAdd = $daysToAdd * 86400; > $dateIn = "2004-07-24"; > $dateInStamp = strtotime($dateIn); > echo date('m/d/Y h:i:s',$dateInStamp+$secondsToAdd); > ?> > > ... as does the more condensed version: > > <? echo date('m/d/Y h:i:s',strtotime("2004-07-24")+(5*86400)); ?> > > If strtotime() is returning -1, that means that it's having trouble > converting your YYYY-MM-DD date to a timestamp. The common pitfall is > that you've got the month and day mixed up (YYYY-DD-MM), or that you're > not using 2 digit numbers on the day and month (and 4 digit on the > year). > > If you're having trouble with strtotime(), ech out the date you're > trying to convert, to make sure it's what you're expecting. > > > It's also worth pointing out that we've made no considerations for > timezones, daylight savings, etc. > > UNIX timestamps are all GMT, so if the times you're seeing are not as > expected (and the dates you're collecting aren't GMT dates, then you'll > need to dig a lot deeper -- it's depends how much accuracy you want. > > Justin French > > On 07/09/2004, at 1:59 PM, 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]) > > > > 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... > > --- > Justin French > http://indent.com.au > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php