convert unix timestamp php

2010-09-14T17:15:00

I have a database that stores the time for me. I insert it from PHP using

date( 'Y-m-d H:i:s');

I then use this function to convert it to a unix timestamp in PHP

function convert_datetime($str) 
{
list($date, $time) = explode(' ', $str);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);

$timestamp = mktime($hour, $minute, $second, $month, $day, $year);

return $timestamp;
}

What I now need to do is convert this timestamp to the date and time in this format: yyyymmddhhmmss (without any hyphens, dashes, colons, etc).

Has anyone any ideas?

Copyright License:
Author:「109221793」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/3707506/convert-unix-timestamp-php

About “convert unix timestamp php” questions

I have a database that stores the time for me. I insert it from PHP using date( 'Y-m-d H:i:s'); I then use this function to convert it to a unix timestamp in PHP function convert_datetime($str)...
I'm confused about timezone differences when converting a MySQL datetime to Unix timestamp. It appears to me that MySQL datetimes (2011-02-07 09:45:00) are in the server's local timezone. I want to
I'm throwing a unix timestamp from my php to my javascript and I noticed that PHP and Javascript timestamps are different (seconds vs. milliseconds) from the epoch. What I'm basically doing is to...
Well, I fetch timestamp from my table using a php page with getJSON. Here is the structure. main.php --> using getJSON (abc.php) --> value from my table Is there any way to convert this UNIX time...
I have a simple question for you. I have a unix timestamp variable in php, let me call it $unix, which contains the current unix timestamp (seconds passed after 1/1/1970 00:00:00 UTC), that by defi...
I am recieving a date which uses javascript's date() function to generate a timestamp like so. 1451351941210 However my application is in php and I would like to convert that value to a unix time...
These both correctly return the current UNIX timestamp: SELECT UNIX_TIMESTAMP(LOCALTIMESTAMP()); #MySql echo time(); //PHP But I'm storing UTC_TIMESTAMPs in my database (not LOCALTIMESTAMPs). Ho...
For a simple PHP graphing script, I need to align time values at local time days. When I do something like $timestamp % 86400 == 0 I get a break at 2 am every day because I'm in UTC +2 here. Also a...
I m getting start time 634942626000000000 and end time 634942638000000000. How can I convert it to a Unix timestamp? I want to display formatted date/time in PHP?
I have an issue whereby a client has some legacy environment (IIS 6 / PHP 5.0.1) and keeps getting the following error: Warning: date() [function.date]: Windows does not support dates prior to

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.