开发者

converting 3 hours ago, 7 hours ago etc into unix timestamp

开发者 https://www.devze.com 2023-03-30 14:56 出处:网络
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
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"

0

精彩评论

暂无评论...
验证码 换一张
取 消