-2

I've got an SQL server 2000 running with some data.
When I select one of my fields I get something like this:

Sep 21 2015 12:00:00:000AM
Sep 14 2015 12:00:00:000AM

..etc

I would like to convert this thing to "DD/MM/YYYY". When I'm doing a query with Access I get this format, but not with PHP.

2 Answers2

1

`your query and see time and take it into a variable then fetch that index that comes with time make three array like

`$ar=array();

    $ar1=array();
    $ar2=array();` after it apply `$ar1[0]=$ar2[0];
    $ar1[2]=$ar[1];
    $ar1[3]=$ar[0]." ".$ar2[1];

then implode like

$dt=implode("-",$ar1);
$data[$k]['time_from']=$dt;

and print $dt you find your structure.

  • Wow sorry but i'm totally lost with that, i'm currently having this date format from my database "Sep 14 2015 12:00:00:000AM" I don't even know why you are using implode with "-". Of course i can extract the first 11 caracters, then explode with " " and rearrange everything but i'm sure that there is a more standard option to convert this format to another. – user5115514 Oct 09 '15 at 09:57
  • @user5115514 i just get a scenario to achieve your goal through array.you just put your date in array same time same year in array then you have three arrays.put values in array then arrange. –  Oct 09 '15 at 10:04
1
$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');
1990rk4
  • 728
  • 11
  • 21