Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Converting dates with PHP for DATETIME in SQL
- $new_date = date( "Y-m-d H:i:s", strtotime( $old_date ) );
- $timestamp = '31/05/2001 12:22:56';
- $timestamp = DateTime::createFromFormat('d/m/Y H:i:s', $timestamp);
- echo $timestamp->format('Y-m-d H:i:s');
- $timestamp = '31/05/2001 12:22:56';
- $timestamp = date_create_from_format('d/m/Y H:i:s', $timestamp);
- echo date_format($timestamp, 'Y-m-d H:i:s');
- function localToMysql($dateTime){
- $date_chunks = explode('/', $dateTime);
- $time_chunks = explode(' ', $date_chunks[2]);
- $final_format = $time_chunks[0] . "-" . $date_chunks[1] . "-" . $date_chunks[0] . " " . $time_chunks[1];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement