Re: Formatting Date (m/d/yyyy) To Timestamp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:
Hi All,

I have a string: '1/1/2021'. I want to turn this into a timestamp for entering into MySql. I have tried everything I could find. Please let me know how to proceed. 

Also, let me know if you need more information.


Thanks:
     Talin Sharma


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux