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
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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

many thanks for that suggestion.

I'm not sure that it takes account of daylight savings etc though. These can result in errors of a couple of hours between a country in the northern hemisphere and one in the southern hemisphere.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.