954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

AS3 - Get timestamp from day start?

Hi, I need to get the UNIX timestamp from when the day started in AS3. How can I do this???

Thanks in advance :)

Kieran Y5
Junior Poster
137 posts since Aug 2010
Reputation Points: 18
Solved Threads: 18
 

oh, well I found out a way.

var time:Number;
var timestamp:Number = 1283297261; // Should be unix timestamp, divide by 1000 if its a microsecond timestamp.
time = Math.min(timestamp / 86400);
time = answer*timestamp;
Kieran Y5
Junior Poster
137 posts since Aug 2010
Reputation Points: 18
Solved Threads: 18
 

Or you could use a 'Date' object... Date is a globally defined intrinsic class/type in AS3 so you don't need to import anything to be able to use it.

var today:Date = new Date(); // constructor sets a new Date object to the current system date/time by default
var current_time:number = today.valueOf(); // valueOf returns the number of milliseconds since midnight on january 1st 1970 (universal time!)


The Date class has loads of different options to return the date in various formats.
I think valueOf() is most likely the one you're after. Otherwise take a look at the documentation for the Date class. I'm sure you'll find a function in there that will suit your needs!

Cheers for now,
Jas.

JasonHippy
Master Poster
772 posts since Jan 2009
Reputation Points: 590
Solved Threads: 125
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: