Hello Everyone
Can anyone guide me how i can convert 4 hours ago, 3 hours ago etc into unix timestamp? It is often observed on many sites some time ago like 3 hours开发者_开发技巧 ago etc , i really need it to convert into unix timestamp, let me know if anyone have any idea?
if it is always in the format "n Hours ago" you can convert n to an integer and then subtract 3600*n from the current unix timestamp.
Without knowing the language you are using it is hard to give a more detailed explanation.
From the command line, date
can do this conversion for you:
date -d "3 hours ago" +"%s"
where +"%s"
is a date format that simply means "print unix timestamp"
精彩评论