Hi, Ive made a flash clock, but it needs to be in GMT, not the time that is picked up from the visitors pc. Does anyone know of a tutorial etc, or have any idea of how to do this? The server is a php one ... Cheers in advance
You need to use getUTCHours instead of getHours...same for Date, Minutes etc...look into flash help for the Date class ;-)
Any idea of a way to convert a string to a time and use it in a clock? I need to get the time from a php file and convert it to a time that can be used in this clock... Here is the working clock actionscript time=new Date(); // time object hours = time.getHours() minutes = time.getMinutes() seconds = time.getSeconds(); seconds = seconds*6; // calculating seconds minutes = minutes*6; // calculating minutes hours = hours*30; // calculating hours sec._rotation=seconds; // giving rotation property min._rotation=minutes; // giving rotation property hour._rotation=hours; // giving rotation property Code (markup): Please help :S
Why do you need to get the time from a php file? You said you need GMT time, GMT time is GMT time no matter where you get it from. Try this: time=new Date(); // time object hours = time.getUTCHours() minutes = time.getUTCMinutes() seconds = time.getUTCSeconds(); seconds = seconds*6; // calculating seconds minutes = minutes*6; // calculating minutes hours = hours*30; // calculating hours sec._rotation=seconds; // giving rotation property min._rotation=minutes; // giving rotation property hour._rotation=hours; // giving rotation property
I dont want to collect the time from the clients pc, i want to collect it from the server, hence the php? Is this workable?
I said you need to use getUTCDate, not getDate. When using getUTCDate in flash, it will return universal time, not the clients PC time. http://livedocs.adobe.com/flashlite...htm?context=LiveDocs_Parts&file=00000483.html
Thanks but... The only thing with that is - that if the client's pc is in gmt, and the time is wrong, so will the time on the clock. Is there a way to get it from a php file?
What do you mean if the client's pc is in GMT? When using getUTCDate, it will return universal time, not the client's PC time, even if the client's PC time is GMT, it should ignore the client's PC time wherever the client is. I'm not that good with php, but you would need to set up a loadVars in flash, and then load your php and parse whatever you need: http://livedocs.adobe.com/flash/8/m...htm?context=LiveDocs_Parts&file=00002329.html
flash runs on client side so you might need to hard-code the timezone and offset from the client's clock.
Not at all possible to collect the time from a php file, parse string as a date then add it to the above function... Some thing like (for example) on (load) { loadText = new loadVars(); loadText.load("getDate.php"); loadText.onLoad = function(success) { if (success) { //trace(success); newsBox.text= this.myNews; } } } This would solve the issue that stargangel mentioned ? Thankyou all for all help by the way
Ok, I don't understand what you are trying to do. Are you trying to get your clock to display GMT time, no matter where the user is? So that it displays GMT time, whether the user is in USA or Australia? Where are you based? Open a new flash document (AS2), and put this code in. Test your movie and tell me what you get: var today_date:Date = new Date(); trace(today_date.getHours()); trace(today_date.getUTCHours()); Code (markup):
OK. I need a clock that uses server time NOT client time, aka gets time from a php file on that server. Can anyone use the code posted earlier to convert the string collected from the php file into time? I dont want a clock that pulls time from the users pc.
PHP, file getDate.php: echo gmdate('D, d M Y__H:i:s'); Code (markup): then in actionscript load up this url, and shove the returned contents into a var named 'dateTime:String'; var dt:String = dateTime.split('__'); var time:String = dt[1]; var date:String = dt[0]; var ts:String = time.split(':'); var hours:String = time[0]; var minutes:String = time[1]; var seconds:String = time[2]; Code (markup):