Jump to content


BrowserBugs

Member Since 07 Feb 2012
Online Last Active Today, 12:33 PM
*****

Topics I've Started

Time Zones: What's the best approach?

14 September 2017 - 12:38 PM

Hi Gang,

 

I'm working on a pet project and yet again I find myself at the mercy of time, more importantly the most logical way to present a drop down list and store the users time zone.

 

I did some digging here, and figured this was a good approach, but I now find myself with an extensive list of 423 options. What i have decided so far is stacking by Region then City, so ...

<option value="Europe/Jersey">Europe, Jersey (GMT +01:00)</option>
<option value="Europe/Kaliningrad">Europe, Kaliningrad (GMT +02:00)</option>
<option value="Europe/Kiev">Europe, Kiev (GMT +03:00)</option>
<option value="Europe/Kirov">Europe, Kirov (GMT +03:00)</option>
<option value="Europe/Lisbon">Europe, Lisbon (GMT +01:00)</option>
<option value="Europe/Ljubljana">Europe, Ljubljana (GMT +02:00)</option>
<option value="Europe/London" selected="selected">Europe, London (GMT +01:00)</option>
<option value="Europe/Luxembourg">Europe, Luxembourg (GMT +02:00)</option>
<option value="Europe/Madrid">Europe, Madrid (GMT +02:00)</option>
<option value="Europe/Malta">Europe, Malta (GMT +02:00)</option>
<option value="Europe/Mariehamn">Europe, Mariehamn (GMT +03:00)</option>
<option value="Europe/Minsk">Europe, Minsk (GMT +03:00)</option>
<option value="Europe/Monaco">Europe, Monaco (GMT +02:00)</option>
<option value="Europe/Moscow">Europe, Moscow (GMT +03:00)</option>
<option value="Europe/Oslo">Europe, Oslo (GMT +02:00)</option>

... but here's the snag, not sure if all are required, I know Jersey follows the same as London, Isle of Man is on the list too but with the region storage it'll be universal enough to use in conversion.

 

Next thing is not sure if this is a logical order for people to use? It is for me, but some people for example would look for say "Mountain Time" which is a time zone but not everyone in the zone follow Daylight Saving.

 

I know storing the zone using "Europe/Jersey" for example is the way to go as it's php friendly for converting from UTC (stored) to local time of user, bit baffled as to the best way to present it for selection.

 

More of a think tank really, any ideas appreciated.


SEO Section Guide

29 April 2017 - 01:17 PM

Hi Gang,

 

Yeah SEO section gets battered a lot by spammers but was just thinking would be nice to have a 'read this first' thread (locked) with links to PageSpeed Insights etc before people post 'whats wrong with my site SEO' threads. Also might help if threads in SEO required approval before starting, or some kind of 'duplicate question' option like stack.

 

Just a thought.


SQL vs PHP: DateTime Issue

07 April 2017 - 09:12 AM

Hi Gang,

 

Bit of a weird one, hoping someone can help. I've a 1 hour gap (UTC/BST) between SQL and PHP.

$q = "UPDATE `table` SET `updated` = NOW() WHERE `id` = ?";
// SQL table updates correctly with BST e.g. 2017/04/07 09:42:00, however the following at the same time...
echo date("Y-m-d H:i:s");
// This shows 2017/04/07 08:42:00 which is UTC.

Might be a bit green here, I always thought SQL time and php time would be the same as it would use system clock or am I missing something?

 

Cheers.

 

Edit: So I made a function for displaying current London time.

function londonTime() {
$a = new DateTime("now", new DateTimeZone("Europe/London"));
$a->setTimestamp(time());
return $a->format("Y-m-d H:i:s");
}

This works, but still not 100% sure why SQL takes BST into account so any explanation would be great, things like this niggle me ;)