<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Swami Charan&#039;s Blog &#187; Unix TimeStamp</title>
	<atom:link href="http://www.swamicharan.com/blog/tag/unix-timestamp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.swamicharan.com/blog</link>
	<description>My personal blog...</description>
	<lastBuildDate>Sat, 17 Jul 2010 13:02:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Unix Timestamp in Flash</title>
		<link>http://www.swamicharan.com/blog/flash/unix-timestamp-in-flash/</link>
		<comments>http://www.swamicharan.com/blog/flash/unix-timestamp-in-flash/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 11:29:50 +0000</pubDate>
		<dc:creator>Swami Charan</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Adobe Flash]]></category>
		<category><![CDATA[Unix TimeStamp]]></category>
		<category><![CDATA[Unix Timestamp in Flash]]></category>

		<guid isPermaLink="false">http://www.swamicharan.com/blog/?p=731</guid>
		<description><![CDATA[Recently i needed to convert normal Time to Unix Timestamp in Flash. I couldn't get how to go about it intially. But when i gone through the definition of Unix Timestamp, its was clear for me.
"The unix time stamp is a way to track time as a running total of seconds. This count starts at [...]]]></description>
			<content:encoded><![CDATA[<p>Recently i needed to convert normal Time to Unix Timestamp in Flash. I couldn't get how to go about it intially. But when i gone through the definition of Unix Timestamp, its was clear for me.</p>
<p><strong><em>"The unix time stamp is a way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970. Therefore, the unix time stamp is merely the number of seconds between a particular date and the Unix Epoch."</em></strong></p>
<p>In order to count the number of seconds till a time, we have method <em>Date.getTime() </em>in Flash. This will effectively return the number of seconds from the Unix Epoch till the Date.</p>
<p>This is how i tried to find out the number of seconds till today's System Time:</p>
<pre class="brush: php;">var myDate = new Date();
trace(myDate);
var unixTime = Math.round(myDate.getTime()/1000);
trace("Unix Time: "+unixTime);</pre>
<p><strong>Output:</strong></p>
<pre class="brush: php;">Fri Jan 22 13:01:55 GMT+0530 2010
Unix Time: 1264145516</pre>
<p><span id="more-731"></span></p>
<p>To verify if we got the correct Unix TimeStamp of the normal time, check it on any online <span style="color: #0000ff;"><a href="http://www.onlineconversion.com/unix_time.htm" target="_self">Unix Timestamp converters</a></span>.</p>
<p>Problem arised when tried to convert the Unix Time we got into normal timestamp in Flash.</p>
<pre class="brush: php;">var myDate = new Date();
trace(myDate);
var unixTime = Math.round(myDate.getTime()/1000);
trace("Unix Time: "+unixTime);

var dateNew = new Date();
dateNew.setTime(unixTime);
trace(dateNew);</pre>
<p><strong>Output:</strong></p>
<pre class="brush: php;">Fri Jan 22 16:22:42 GMT+0530 2010
Unix Time: 1264157563
Thu Jan 15 20:39:17 GMT+0530 1970</pre>
<p>If you observe closely, while converting the Unix Timestamp to normal time, the year that's returned is <strong>1970</strong>. If we use a online <span style="color: #0000ff;"><a href="http://www.onlineconversion.com/unix_time.htm" target="_blank">Unix Timestamp Converter</a></span> to get back the normal time, it returns approximately correct time by inputting the above Unix Timestamp.</p>
<p>That was strange to get the difference while converting Unix Timestamp to Normal TimeStamp. Just observed this behavior, so thought of sharing it to find a solution or answer how to overcome it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swamicharan.com/blog/flash/unix-timestamp-in-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
