1

I'm developing a PHP project and I'm using Parse SDK. What i want to do is adjust the time given by the Parse Database. It gives me time and date that 8 hours late to my timezone. Here's the code I'm using :

$query = new ParseQuery("TestObject");
$query->get("xWMyZ4YEGZ");
$dateTime = $query->getCreatedAt();
$sched = $dateTime->format("M d, Y - hA");
echo $sched;

How can i adjust it to specifically "GMT+8" TimeZone? Thanks!

LEVIS OGCPAS
  • 229
  • 4
  • 11

2 Answers2

0

You have to set the date_default_timezone_set before doing any thing as:

if(function_exists('date_default_timezone_set')) 
          date_default_timezone_set($timezone);

List of timezones are provided here...

Vineet1982
  • 7,730
  • 4
  • 32
  • 67
0

Have a look at PHP date with TZ - See N.B.'s answer here is a code snippet he suggests (you may be able to use the parse date instead of the "now" parameter):

<?php
$tz = 'Europe/London';
$timestamp = time();
$dt = new DateTime("now", new DateTimeZone($tz)); //first argument "must" be a string
$dt->setTimestamp($timestamp); //adjust the object to correct timestamp
echo $dt->format('d.m.Y, H:i:s'); 
Community
  • 1
  • 1
RyanNerd
  • 3,059
  • 1
  • 22
  • 28