I am not a PHP expert. I have been
programming in other languages for about half a century. I assume you want to do the conversion using PHP, not SQL. I had forgotten what a UNIX timestamp is but I see that it is defined as the number of seconds since January 1st, 1970 at UTC. When I look at PHP: Date and Time Related Extensions - Manual I find the DateInterval class. It can be used to determine the number of seconds between two dates. Can you convert the specified dates to DateTime objects? Since the UNIX timestamp is the number of seconds since January 1st, 1970 at UTC, the difference between January 1st, 1970 at UTC and a specified date is the amount of time since January 1st, 1970 at UTC and that difference in seconds is the UNIX timestamp. Right? Something to look closely at is what precise time to use. Is the timestamp supposed to be for the first second or the last second of a specified day? Talin Sharma wrote on 1/10/2021 3:17 PM:
|