mktime to subtract minutes (was Time without seconds)

From: Date: Wed, 18 Jun 2003 08:45:45 +0000
Subject: mktime to subtract minutes (was Time without seconds)
Groups: php.db 
Request: Send a blank email to php-db+get-28706@lists.php.net to get a copy of this message
I realized I need to do some processing on the time after it's retrieved, so I decided to retrieve hours and minutes separately and then subtract the necessary time with PHP. Each city has sunset times for each day stored in the database, in a datetime field. I retrieve all cities and times for a today's date, and then loop through the results to display them in a table. Depending on which city it is, though, I need to subtract a certain amount of time - 18 minutes for one, 20 minutes for another, and 40 for the third. I thought the best way to do this would be to use a combination of mktime and date, and this works for adding an hour if daylight savings time is in effect. $hour = $dst ? $sunset_a[hour]+1 : $sunset_a[hour]; $time = mktime ($hour,$minute,0,1,1,2003); $time = date("G:i", $time); But how do I do this for minutes? If I do this: $minute = $sunset_a[minute]-40; and plug that into the mktime line above, I get the wrong answer: 24:00 - 40, not $sunset_a[minute] - 40. Is there no easy way to subtract time n PHP, like in MySQL with DATE_SUB? Or am I missing something easy with mktime? TIA, -Lisi

« previous php.db (#28706) next »