0

how to covert date format in table mysql using php, From this format 2016-07-02T17:04:18+00:00 To Sat, 02 Jul 2016 17:04:18 GMT ?

Thank you very much,

Azzabi Haythem
  • 2,318
  • 7
  • 26
  • 32

1 Answers1

-1

read the value from mysql to variable info

then use;

$in = "2016-07-02T17:04:18+00:00";
date_default_timezone_set('GMT');
$out = date("D, d M Y G:i:s e",strtotime($in));
echo $out;

write the value back if desired info

assumed that value you listed is varchar as it doesnt appear as a standard mysql datetime format. here and that you understand how to query the database.

if the value is datetime as your post seems to lead too. then try the code, as strtotime should understand the format fine. but the code will be to convert and output the date elsewhere, not write back into mysql as dateime as it doesnt work like that.

also see;

Convert from MySQL datetime to another format with PHP

How to convert date from one format to another in Php

Community
  • 1
  • 1
2114L3
  • 564
  • 5
  • 8