How to convert a GMT timestamp to proper Date in PHP?

How does one convert this date into a PHP timestamp?

  • PHP Code: <?php $signup = $user['signup']; // $user['signup'] --> 2014-01-18 04:54:21 echo date(" F jS, Y H:i:s A", strtotime("$signup")); // output --> January 18th, 2014 04:54:21 AM ?>

  • Answer:

    There is no such a thing as "PHP timestamp". There are 2 types of timestamps commonly used in PHP: UNIX timestamp and MySQL timestamp. The 1st is got by $time=strtotime($str), the 2nd - by date("YmdHis",$time).

Seva Lapsha at Quora Visit the source

Was this solution helpful to you?

Other answers

You can use this function. Takes in a MySQL date time format and returns a PHP timestamp. function php_timestamp($yourMySQLDateTime){ list($date, $time) = explode(' ', $yourMySQLDateTime); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $timestamp = mktime($hour, $minute, $second, $month, $day, $year); return $timestamp; }

Prithvi Raj

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.