mktime to subtract minutes (was Time without seconds)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux