PHP convert MySQL datetime to Unix Timestamp

2011-02-04T04:23:41

I'm confused about timezone differences when converting a MySQL datetime to Unix timestamp. It appears to me that MySQL datetimes (2011-02-07 09:45:00) are in the server's local timezone. I want to convert this datetime into a Unix timestamp, which is always in the GMT timezone. To do this conversion, PHP passes the datetime into strtotime. The datetime string contains no timezone, so will strtotime assume the argument is local timezone or GMT?

Copyright License:
Author:「JoJo」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/4891295/php-convert-mysql-datetime-to-unix-timestamp

About “PHP convert MySQL datetime to Unix Timestamp” questions

I'm confused about timezone differences when converting a MySQL datetime to Unix timestamp. It appears to me that MySQL datetimes (2011-02-07 09:45:00) are in the server's local timezone. I want to
These both correctly return the current UNIX timestamp: SELECT UNIX_TIMESTAMP(LOCALTIMESTAMP()); #MySql echo time(); //PHP But I'm storing UTC_TIMESTAMPs in my database (not LOCALTIMESTAMPs). Ho...
im using php 5.4.6 and MySQL 5.5.29 and I get trouble by converting a UNIX TIMESTAMP to MYSQL DATETIME and vice versa. Mysql and php wun on the same local machine. I have a simple mysql table CRE...
Problem Converting unix timestamp to datetime while retaining milliseconds. Background I am receiving unix timestamp in the following format: 1584049707 Then I am trying to send it by means of...
How do I convert timestamps in a MySQL View? I have a MySQL View for data exchange between 2 different software tools. The original table is a unix timestamp as int(11). The other software expec...
I was reading over an article that shows some really good information and benchmarks about how well the three different MySQL date/time storage options perform. MySQL DATETIME vs TIMESTAMP vs INT
I've seen the instructions for converting back and forth between a UNIX epoch and a datetime in MySQL -- it's not too hard (from_unixtime to convert from epoch to datetime, unix_timestamp to get the
I'm attempting to call LinkedIn's API and store Network Updates. Each update has a Unix timestamp that I'm retrieving as a string variable from the REST XML response. I want to convert the string
I have an issue with CakePHP's query builder trying to select a DATETIME field and using the UNIX_TIMESTAMP() function. This is my custom finder: public function findApi(Query $query, array $
I have a database that stores the time for me. I insert it from PHP using date( 'Y-m-d H:i:s'); I then use this function to convert it to a unix timestamp in PHP function convert_datetime($str)...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.