You want to convert between DMYHMSM format (days, months, years, hours, minutes, seconds, milliseconds) and Epoch milliseconds.
Use the getTime( ) and setTime( ) methods.
Most of us are more comfortable thinking of dates and times in terms of components such as hours, days, and years than working with Epoch milliseconds or seconds. For example, it is generally more meaningful to humans to discuss the time and date 3:55 A.M., Friday, October 13, 1978 than to discuss the corresponding Epoch milliseconds value of 277124100000. However, languages such as ActionScript store times in Epoch milliseconds (or Epoch seconds) format. Therefore, it is important to be able to convert between different formats when displaying dates and times to users or when sharing dates between applications that use different formats.
// Construct a date for 3:55 AM, Friday, October 13, 1978.
// The output may vary depending on your time zone.
You can pass the Epoch seconds value returned by getTime( ) to another application (such as a CGI script) or use it to perform date mathematics (see Recipe 10.6).
On the other hand, you may want to set a date using the Epoch milliseconds. For example, in Recipe 10.1, the CGI script returns the current server time to Flash in Epoch seconds (which needs to be converted to milliseconds by multiplying by 1,000). Also, when performing date mathematics you may want to set a date according to Epoch milliseconds. You have two options for setting a date according to Epoch milliseconds. One choice is to pass the milliseconds value to the Date constructor as the only parameter, and the other is to pass the milliseconds value to the setTime( ) value of an existing date. Both techniques are effectively the same. The only reason to use the setTime( ) technique rather than the Date constructor is if you have assigned any custom properties to an existing date that would be lost by calling the constructor.
// the value displayed in the Output window from the preceding example.
// Create a Date object.
// Assign a custom property to the Date object.
// Use the setTime(  ) method to set the date to 3:55 AM, Friday, October 13, 1978.
// This doesn't overwrite the label property, as calling the Date constructor would.
After assigning a value to a date using the setTime( ) method, you can use getDate( ), getMonth( ), getYear( ), getHours( ), getSeconds( ), getMinutes( ), and getMilliseconds( ) methods to retrieve the individual DMYHMSM values in the local time. To retrieve the UTC date and time, use getUTCDate( ), getUTCMonth( ), getUTCHours( ), getUTCSeconds( ), getUTCMinutes( ), and getUTCMilliseconds( ) instead. See Recipe 10.6.