Easy Unix Time Function
Line Break
Author: Theo (4 Articles) - Author Website
Theo is a SAP Integration Specialist by day and a Webdeveloper / Web App Evangelist by night. He is the creator of "I Am Bored So I blog" and he is a member of the Board of the Dutch Flex Usergroup. With his quote "Never Give Up, Never Surrender" (Actually stolen from Galaxy Quest) he fights his way through the day.
Today I was in need of a function that would give me the current Unix Time. It might be possible that you don’t know what the Unix Time is exactly, check out this Wikipedia article.
In my need to get this time, I wrote the following quick and simple code.
It’s actually only 3 lines of code (well 5 with the function statement around it)
1 2 3 4 5 | public function GetUnixTime():String{ var myDate:Date = new Date(); var unixTime:Number = Math.round(myDate.getTime()/1000); return unixTime.toString(); } |
That’s it !
If you want to show it in eg a TextInput just do this :
1 | txtInput.text = GetUnixTime() |
Related posts:
Comments
One Response to “Easy Unix Time Function”





thanks and yes this was very helpful