I have a date and timestamp in HL7 format : 201402181659
That represents 2014 02 18 at 16:59
it's offset by +11:00 hours so I need to be able to add 11 hours to the date/time. Any ideas?
I have a date and timestamp in HL7 format : 201402181659
That represents 2014 02 18 at 16:59
it's offset by +11:00 hours so I need to be able to add 11 hours to the date/time. Any ideas?
You can use DateTime::createFromFormat()
to parse the string and then DateTime::modify()
to add 11 hours to it:
$date = DateTime::createFromFormat('YmdHis', '201402181659');
$date->modify('+11 hours');
echo $date->format('YmdHis');
You can also use DateTime::add()
with DateInterval()
to add the 11 hours:
$date = DateTime::createFromFormat('YmdHis', '201402181659');
$date->add(new DateInterval('PT11H'));
echo $date->format('YmdHis');