Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : How to get serve time?


Szeki
3/7/2004 6:58:03 PM
Hi!

I'm trying to get the server's time on which my swf is uploaded. Every
date/time functions I tried, show the client's date/time. Do you know any other
functions/tricks which would do? I want the date to be independent of the
user's system clock.

Thanx, Szeki

today_date = new Date();
datestring=today_date.getUTCDate();
Ivan Peters
3/8/2004 11:07:14 AM
There is no easy way to do that. You will need to create a script on the
server that returns the time and call that script using something like
loadVariables().

[quoted text, click to view]

Szeki
3/8/2004 8:18:24 PM
What I thought about is that I write a javascript that reads server time in
and writes it into a file, then the swf can read it in from the txt file.
Do you think it should work?

The problem is that I don't know how to calculate difference between two date
variables, should I just subtract them from eachother?

Szeki
Ivan Peters
3/10/2004 10:57:51 AM
JavaScript doesn't have a way to get the server time either. So you'd have
the same problem.

But, if you can get the server time into the HTML page somehow then you can
use JavaScript to pass it to the swf:

http://www.macromedia.com/support/flash/ts/documents/java_script_comm.htm

Also, look up "Using HTTP to connect to server-side scripts" in the help.

All dates can be converted to a number (in milliseconds). Do all your
calculations in milliseconds and convert back to whatever time units you
need. More info can be found in the help.

If you want to do more complex date calculations then you will find lots of
example ActiveScript and JavaScript code on the internet (for this purpose,
JavaScript is just the same as ActionScript so JavaScript code will usually
work just fine).

Ivan

[quoted text, click to view]

AddThis Social Bookmark Button