Technical & Scientific > Programming

Handling timezone conversion

(1/2) > >>

ober:
So I'm freelancing an app and this is the first time I'm trying to handle timezone conversion.  Everything is stored in the DB as UTC and I've got the profile setup correctly with the timezone.  According to StackOverflow, I'm doing it correctly, but the load time for my overview screen increased dramatically.  Like I'm doing local development with a vagrant box and prior to the change, loading ~25 records was almost instant.  Now it's taking almost 3 seconds.

I do the following:

--- Code: ---$usersTimezone = new \DateTimeZone($_SESSION['tz']);  // this is outside the loop
foreach($row as $key) {
  // get other fields
  $updated = new \DateTime($key->updated);
  $updated->setTimeZone($usersTimezone);
  $outrow['updatedate'] = $updated != '' ? $updated->format("n/j/Y") : "Never";
}
[code]

I wonder if I could create the DateTime object once and reuse it?


--- End code ---

ober:
I guess I have a different question.  I'm setting the PHP (application) timezone to be UTC (date_default_timezone_set('UTC');).  If I change that timezone setting in PHP for each user, will the DB store a central value that will convert for other users? 

Ugh, I need to do some testing.

ober:
So... finally got back to this.  I'm a fucking idiot and I was passing the wrong variable to the date functions.  The added time was the app dumping a ton of errors to the error log.  Ooops! 

KnuckleBuckett:
Prolly all that hair over your eyes. 

Check this shit out.

https://www.amazon.com/Unisex-Spring-Accessory-Beauty-hair/dp/B00IP5Y4CM/ref=sr_1_1_s_it?s=beauty&ie=UTF8&qid=1478253538&sr=1-1&keywords=hair+holder

YW

ober:
Perfect!  I've been looking for one just like that!

Navigation

[0] Message Index

[#] Next page

Go to full version