Does AS3 have a way of converting a datetime variable into local time?
Asked
Active
Viewed 3,897 times
1 Answers
4
//Some date string you got from somewhere
var dateStr:String = "Sun Sep 25 22:30:33 GMT+0600 2011";
var date:Date = new Date(dateStr);
//Use date.toLocaleString() to get a local time string and create a new date from it
var localDate:Date = new Date(date.toLocaleString());
trace(localDate);'
Here's a link to date.toLocaleString() from Adobe

Yogev Shelly
- 1,373
- 2
- 13
- 24
-
Ah, so I can pass in a time string to Date(). Thanks. – Francisc Sep 25 '11 at 18:08
-
There's no point creating a new Date object from date.toLocaleString(). That only creates a new Date object identical to the first. Just 'trace(date)' to see. – dazweeja Feb 01 '12 at 00:42