Format String to insert in Mysql (TIMESTAMP)

1

I need to insert a string which looks like this:

"2014-11-25T14:13:35.000Z"

in a MySql database and using PHP in a TIMESTAMP field.

How can I format the string for insertion using PHP?

    
asked by anonymous 25.11.2014 / 18:56

2 answers

1

You can also do this by using the function that Silvio has commented with the function date to format before inserting into the database:

$timestamp = date('Y-m-d H:i:s', strtotime("2014-11-25T14:13:35.000Z"));
    
25.11.2014 / 19:26
0

You can use strtotime

$timestamp = strtotime("2014-11-25T14:13:35.000Z"); // 1416924815
    
25.11.2014 / 19:13