How can I convert (string) timestamp to mysql datetime on Windows 32 bit PHP?
Posted
by
user239619
on Stack Overflow
See other posts from Stack Overflow
or by user239619
Published on 2010-12-30T15:51:05Z
Indexed on
2010/12/30
15:54 UTC
Read the original article
Hit count: 166
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 timestamp to a mysql datetime format. The date() function accepts an integer as the second argument for time to be converted. However, I'm on Windows 32 bit PHP and the integer type for this platform is limited to 2147483647.
$timestamp = '1293714626675'; // sample pulled from linkedin
$timestamp = (int) $timestamp; // timestamp now equals 2147483647
$mysqlDatetime = date('Y-m-d H:i:s', $timestamp); // produces incorrect time
Is there a better method of creating the mysql datetime in PHP? I realize that I can convert it upon insert into MySQL however, that would require changing other dependent code.
© Stack Overflow or respective owner