First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Nuno Mira | Website:


If you don’t have access to a PHP enabled server you can easily install one locally.
WampServer and XAMPP are the most common ones. You will get Apache, PHP and MySQL and with this a whole new world of possibilities.

PHP offers several date related functions. As you're interested in the number of milliseconds after 0:00:00 GMT January 1, 1970, time() seems like the perfect choice. Unfortunately, this doesn't really serve our purpose, as the value returned by time() is relative to 0:00:00 GMT January 1, 1970 which means it is independent from the server's timezone.
You'll have to use some math here as well, to take the server's timezone into account.
Also note that this value is in seconds and not milliseconds, which is the unit that Flash requires.

The date() function returns a string with the value formatted according to the values passed to it. When the second parameter is ignored, the current time is used.
For example, date('YmdHis') returns a very useful string such as 20110228142400. which can be looked at as: yyyymmddhhmmss.

The parameter Z (see the documentation) will return exactly what you need - the timezone offset in seconds - date('Z').
After converting the string returned by date('Z') to an integer using strtotime(), you're ready to go:

$offset =  strtotime (date('Z') );
$seconds = time() + $offset;
echo "seconds=" . $seconds;

You may also output the server time to help you debug and make sure that every thing's fine.

$offset =  strtotime (date('Z') );
$seconds = time() + $offset;
echo "seconds=" . $seconds;
echo "&date=" . date('YmdHis');

If you open server-time.php directly in your browser you'll see something like


i.e., two variables: seconds and date.
Only seconds matters and only seconds will be accessed in Flash.


In ActionScript 2, when loading variable name/value pairs, it was common to start and end the string with ampersands:


In ActionScript 3 this will create an error so, make sure that you only use the ampersand (&) to separate the variable name/value pairs:

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
	at Error$/throwError()
» Level Intermediate

Added: 2011-02-28
Rating: 3.25 Votes: 4
(10 being the highest)
» Author
Nuno Mira has been a Flash Developer for 9 years. He loves teaching, and learning. When he isn't coding he may be surfing or snowboarding.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.