NUGGET
NUGGET

Reputation: 61

How to convert time to epoch

How can I convert the following code below to epoch time?

starts = '" . date("Y-m-d h:i:s", strtotime($_POST['starts'])) . "',

I have been racking my brain for the last two days and I just cannot figure it out.

I am getting the date and time from datetimepicker and I need to convert the time from unix timestamp to epoch to store in the database. Thanks in advance for help.

I'm using this command to write to MYSQL database

Upvotes: 0

Views: 583

Answers (1)

Abhishek Kannan
Abhishek Kannan

Reputation: 988

strtotime($starts);

http://php.net/manual/en/function.strtotime.php

Refer the php documentation for more details.

Note : UNIX Epoch is always in UTC. So always set the default timezone using the date_default_timezone_set(); function to get the desired output.

Upvotes: 1

Related Questions