Jump to content

what time is it over there?


mouli

Recommended Posts

I have several sites that use the date function to write the local date and time in New Zealand to the page.

This worked fine until I moved all my sites to a server in another time zone (the USA).

I need to continue writing the New Zealand date and time to the page, not local USA time.

I'm aware that I can apply a time zone offset to the output of the date function but I'm not sure that this can compensate for local summer time changes etc.

The way I'd like to do it is to get the date and time from a server in the original time zone (New Zealand) so it is always accurate.

Has anybody got any ideas how I might achieve this or suggest a better way to do this?

 

Many thanks

 

Link to comment
https://forums.phpfreaks.com/topic/56181-what-time-is-it-over-there/
Share on other sites

you have certainly raised an interesting question.  :D

 

you can get the time for different timezones using Javascript, But I don't know if you could implement it into your current coding.

 

Heres an example of getting the time in Tokyo. and the time of UTC.

<script type="text/javascript">
// create a new Date object
var now = new Date();

// store local time - in this case Tokyo, Japan
var jpn = "Tokyo Time:\n" +now.toString()+ "\n\n";

// store GMT time
var gmt = "UTC Time:\n" + now.toGMTString();

// display Local time and GMT time
alert(jpn + gmt);
</script>

 

just an example of how it can be done.

 

Regards ACE

you can use timezones in php too...

 

You can either have people store there favoured time zone Or (more intensive) use something lie kgeoip to detect wher ethey are automatically.  Factor the result into yout date/time function use.

I've got a page on a new zealand server that, when called generates the unix time stamp on that server. So in effect I have a URL that returns the time stamp.

Any idea how I can use this in a page in the USA to allow me to manipulate the timestamp.?

How do I call the URL so I can get my spanners on the timestamp?

 

Many thanks

 

mouli

 

Hi

No I haven't tested that solution yet. I think it maybe works with php5 only. I'm using php4.4.

I'm also not sure how it allows for daylight saving on a server in the remote time zone. Of course it knows its local time including DLS but does a server in USA know what the actual time is in Auckland new zealand.

I have access to a server in NZ so I'm working on a simple solution that includes a page on the NZ server that returns the NZ timestamp, then I can easily echo NZ time, date etc.

 

Thanks for yur help

 

mouli

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.