Reputation: 25753
In most of the Programming or scripting language such as PHP or JavaScript, i have come across the time function which tends to calculate the time from year 1970. for example in javascript if i use the function getTime() or in PHP the time() it returns an integer value.
In PHP.
the code with <?php echo time(); ?>
returns an integer value of 1281694425,
what does the value returned by the PHP explains? how and when it is useful?
the same in javascript the getTime() returns the float value since 1970 as it says. by using the below script in JS
<script type="text/javascript">
var d=new Date();
document.write(d.getTime() + " milliseconds since 1970/01/01");
</script>
i want to know when is this type of functions useful to use? and how do we use it?
P.S: is it useful for calculating the time interval? or it is used for storing the current time stamp?
Upvotes: 5
Views: 3554
Reputation: 935
If you want to know the history of this time representation, look at this: http://en.wikipedia.org/wiki/Unix_time.
Upvotes: 6
Reputation: 329
It means you if you recalculate the time from the integer in another time zone you will get the correct time for whichever timezone is accessing it. I believe :-)
Upvotes: 1
Reputation: 32051
It give you the seconds which passed by since the 1st January 1970. This is useful fore several reasons:
Upvotes: 7