I have date string in this format:
2009-07-15 00:00:00 - 2009-07-15 08:16:23
Could anyone help me to tweak the date string to unix timestamp into something like this:
1247634000 - 1247663783
I am using GMT-5
Timezone.
What JavaScript or jQuery techniques could be used?
In JavaScript, in order to get the current timestamp, you can use Date. now() . It's important to note that Date. now() will return the number of milliseconds since January, 1 1970 UTC.
UNIX_TIMESTAMP() : This function in MySQL helps to return a Unix timestamp. We can define a Unix timestamp as the number of seconds that have passed since '1970-01-01 00:00:00'UTC. Even if you pass the current date/time or another specified date/time, the function will return a Unix timestamp based on that.
I strongly advise you to use Moment Date lib when working with dates in js. It's really light and awesome.
var timeStamp = ( moment('2009-07-15 00:00:00').unix() )*1000
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