Peter Rundle wrote:
Sluggers,

After the huge response to the C programing question of last week, here's one in a 'C' syntactic look a like.

<?php
$time=array(
  "2005-10-30 01:59",
  "2005-10-30 02:01",
  "2005-10-30 02:05",
  "2005-10-30 03:01");

foreach ($time as $t)
  print "  $t ==> ".strtotime($t)."\n";
?>

Produces;

  2005-10-30 01:59 ==> 1130601540
  2005-10-30 02:01 ==> 1130601660  <---
  2005-10-30 02:05 ==> 1130601900
  2005-10-30 03:01 ==> 1130601660  <--- Opps going back in time here!

Ok so the issue is daylight savings. How can I convert the said list of dates (which are in UTC) to epoch seconds (which are also UTC) using php *without* changing the timezome of the server (Sydney time)?

"strtotime" doesn't have a timezone argument. Does anyone have a good alternative?

"2005-10-30 01:59+0" didn't work btw.

(Php 5.0.4 on FC4 if that's of importance)

TIA's

Pete.

You could try mktime or gmmktime. I think they have a parameter to force non-daylight-savings which should give the same time as UTC. Little inconvenient in terms of the input date and time though.

Fil
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to