I’m trying to create an accurate Unix timestamp to assign to a variable, based on different time periods. Any idea how these timestamps periods can be calculated?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I could only suggest to you to read the time Manual.
http://php.net/manual/en/function.time.php
Today to last midnight -> Get Hours + Minutes, do a Minus 24:00 hour calculation, use http://php.net/manual/en/function.abs.php to get your value positive
All the others are solvable by using http://php.net/manual/en/function.strtotime.php
In the worst case convert it to unix time and get the difference, you will have an accurate output without paying any attention to the leapyears and other time conditions which you have mentioned like the 28/29 feb problem.