It is actually two way to remove unnecessary Zeros
(1) ltrim()
Example : echo ltrim(”001″,”0″);
Result : 1
(2) intval()
Example : echo intval(”001″);
Result : 1
Conversion of MySQL Timestamp and DateTime to Unix based TimeStamp
Posted by
Divyのsh Karelia
at
10:03 PM
About MySQL TimeStamp
* The Prior version of MySQL v4.1 the timestamp was formatted as like YYYYMMDDHHMMSS”
* since after MySQL v4.1 timestamp and datetime data types are formatted “YYYY-MM-DD HH:MM:SS”.
About Unix Based TimeStamp
* It is differ from MySQL. Unix’s timestamp is a integer value of seconds since January 1, 1970.
How To - Convert
(1) Using MySQL
* you can use Unix_Timestamp() function.
* Example:
SELECT Unix_Timestamp(Created) FROM CreatedItem;
(2) Using PHP
* you can use strtotime() function.
* Example:
$unixTimeStamp = strtotime($createdTimestamp);
* The Prior version of MySQL v4.1 the timestamp was formatted as like YYYYMMDDHHMMSS”
* since after MySQL v4.1 timestamp and datetime data types are formatted “YYYY-MM-DD HH:MM:SS”.
About Unix Based TimeStamp
* It is differ from MySQL. Unix’s timestamp is a integer value of seconds since January 1, 1970.
How To - Convert
(1) Using MySQL
* you can use Unix_Timestamp() function.
* Example:
SELECT Unix_Timestamp(Created) FROM CreatedItem;
(2) Using PHP
* you can use strtotime() function.
* Example:
$unixTimeStamp = strtotime($createdTimestamp);
Labels:
MySQL
Subscribe to:
Posts (Atom)