That's what I tried, but when the minutes are less than 40 it doesn't work
I guess because you get negative. Actually, I'm not sure it even workied
for the one that was more than 40. Is there a way to do taking into account
hours as well without having to code by hand "if minutes < 40 " ... etc.?
Maybe I shouldn't be dealing with hours and minutes separately.
It's so easy in MySQL, but if I do it there I have to do a separate query
for each city - not the worst thing, there are only about 5, but it doesn't
seem very efficient.
-Lisi
At 09:57 AM 6/18/03 +0200, Snijders, Mark wrote:
hi,
i'm not sure if I get the point, but can't you do it like this:
for the minutes: (but when minutes is smaller as 40 you will get a negative
digit, so maybe also use the hours with it.
mktime (0,sunset_a[minute]-40,0,0,0,0);
tell me if it works otherwise i can look for another solution
-mark-
-Original Message-
From: Lisi [mailto:[EMAIL PROTECTED]
Sent: woensdag 18 juni 2003 10:46
To: PHP-DB
Subject: [PHP-DB] mktime to subtract minutes (was Time without seconds)
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
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php