-1

I have a date like this

2015-10-09T19:30:00

list($y, $M, $d, $h, $m, $s) = sscanf($instance->Start, "$d-$d-$dT$d:$d:$d");

^ I am trying to apply this sscanf to split the components up but I am getting bugs at the T section

ultimately want something like this

$z = "Europe/London";
$timestamp = $d."-".$M."-".$y."T".$h.":".$m.":".$s." ".$z;
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
The Old County
  • 89
  • 13
  • 59
  • 129

2 Answers2

1

You can use DateTime Interface -

$date = new DateTime('2015-10-09T19:30:00');
echo $date->format('d-m-Y').' T '.$date->format('H:i:s').' Europe/London';

Output

09-10-2015 T 19:30:00 Europe/London

correct answer

echo $date->format('d-m-Y').' UTC '.$date->format('H:i:s').' Europe/London'; 
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
1
<?php

$date = "2015-10-09T19:30:00";
$z = "Europe/London";

sscanf($date, "%d-%d-%dT%d:%d:%d", $year, $month, $day, $hours, $minutes, $seconds);

$timestamp = $day."-".$month."-".$year."T".$hours.":".$minutes.":".$seconds." ".$z;
echo $timestamp;

?>
PHPeter
  • 567
  • 6
  • 19