0

I want to convert timestamp to datetime string, but not using server timezone like

$datetime = date('Y-m-d h:i:s', $timestamp);

because date will use server timezone to make datestring. I want to use $timezone as param for converting.

dzona
  • 3,323
  • 3
  • 31
  • 47
  • Is `$timestamp` a Unix Timestamp? – John Conde Oct 09 '14 at 20:02
  • See http://stackoverflow.com/a/20288830/2512304 – Radzikowski Oct 09 '14 at 20:02
  • you can't. date() doesn't accept any timezone options. you'd have to use [DateTime](http://php.net/manual/en/datetime.settimezone.php) instead. – Marc B Oct 09 '14 at 20:03
  • @JohnConde Yes, it is unixt timestamp – dzona Oct 09 '14 at 20:06
  • @MarcB DateTime() uses datetime string as param, and I have to change timestamp to datetime string, and that is the problem I have in the beggining. I know date() don't take timezone as param, and that is why I want to make function which will have to timezone param – dzona Oct 09 '14 at 20:08
  • 1
    yes, but there's date_create_from_format so you can feed in a time string AND timezone. – Marc B Oct 09 '14 at 20:14
  • @MarcB yeah, you're right :) I'll make answer to this question with php function. Tnx – dzona Oct 09 '14 at 20:31

0 Answers0