This is what I do in Ruby.
time = Time.now
=> 2013-10-08 12:32:50 +0530
time.to_i //converts time to integer
=> 1381215770
Time.at(time.to_i) //converts integer to time
=> 2013-10-08 12:32:50 +0530
I'm trying to implement the same with Node.js, but not sure how to do it. Kindly help me in finding a module for implementing the same with Node.js, Javascript. Thanks!
A simple method would be this: function getTime() { var now = new Date(); return ((now. getMonth() + 1) + '-' + (now.
The new Date() gives the current date and time. To convert the name to a number, we use the getTime() method. The getTime() method returns the number of milliseconds from midnight of January 1, 1970 (EcmaScript epoch) to the specified date.
strftime() object. In this method, we are using strftime() function of datetime class which converts it into the string which can be converted to an integer using the int() function. Returns : It returns the string representation of the date or time object.
parseInt(timef[1]); int second=Integer. parseInt(timef[2]); int temp; temp = second + (60 * minute) + (3600 * hour); System. out. println("seconds " + temp);
In javascript world.
Date.now()
and
new Date(1381216317325);
In addition to user10 answer
Date.parse("2013-10-08 12:32:50 +0530");
will get you time as integer
EDIT
Date API
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With