Convert a string date to a timestamp

后端 未结 5 1635
无人及你
无人及你 2021-01-31 22:34

Is there any simple way to convert a RFC HTTP date into a timestamp in Lua?

\"Sat, 29 Oct 1994 19:43:31 GMT\"

into

783467011

5条回答
  •  孤独总比滥情好
    2021-01-31 22:43

    use luadate, you can install it with luarocks.

    date = require 'date'
    local d1 = date('Sat, 29 Oct 1994 19:43:31 GMT')                                                                                               
    local seconds = date.diff(d1, date.epoch()):spanseconds()
    print(seconds)
    

提交回复
热议问题