-4

Yes, I know there are a lots of other topics about it, but my problem is here:

I only can use

date_format(new DateTime($ymd_date_from_db), “d.m.Y H:i:s“

when I set the timezone in my php. but I dont want to set it, because there is no need for timezone, because the timestamp value is already in $ymd_date_from_db - so i dont want to set timezone in php in addition to that. also date(....) does not work:

"It is not safe to rely on the system's timezone settings "

  • same problem , it wants me to set timezone in php.

Are there other solutions?

Steven
  • 149
  • 1
  • 10

3 Answers3

0

Try using strtotime():

date("d-m-Y", strtotime($originalDate));
Rizier123
  • 58,877
  • 16
  • 101
  • 156
Ian Devlin
  • 18,534
  • 6
  • 55
  • 73
0

Try using the format method

<?php
    $date = new DateTime($ymd_date_from_db);
    echo $date->format('d-m-Y');
?>
Jordi Kroon
  • 2,607
  • 3
  • 31
  • 55
  • it fgives me same error: It is not safe to rely on the system's timezone settings – Steven Feb 15 '15 at 17:02
  • Do you have access to the apache config file? If so, use the steps outlined here: http://stackoverflow.com/a/16765214/1572528 – Jordi Kroon Feb 15 '15 at 19:26
0

DateTime::format() e.g:

$DateTimeObj->format('your format')
Kamil Karkus
  • 1,283
  • 1
  • 11
  • 29