Check whether the string is a unix timestamp

后端 未结 12 1837
挽巷
挽巷 2020-11-27 16:43

I have a string and I need to find out whether it is a unix timestamp or not, how can I do that effectively?

I found this thread via Google, but it doesn\'t come up

12条回答
  •  萌比男神i
    2020-11-27 16:53

    In PHP for checking if a timestamp represents a valid Gregorian date this worked for me:

    function checkdateTimestamp($timestamp) {
        return checkdate((int)date('m',$timestamp),(int)date('d',$timestamp),(int)date('Y',$timestamp));
    }
    

提交回复
热议问题