After much thought and consideration about the whole process and what needs to be done. I then wanted to start testing to see how this might start to look in the web app. This post will cover some of the thought and testing process I used to work through how the process will work when it is finished.

Firstly I know that all classes that have been created so far are all in Australia/Brisbane timezone. So I know the offset for Brisbane is 36000 (+ 10 Hours). Eventually this will be stored in the database but for now I can store it as a static variable in the configuration file like this

I then need to work out the current time zone offset from UTC for the calculations. I can do this using the date command

Then I want to workout the difference between the class start date when it was originally created and the current time zone offset (i.e. to account for DST etc). This may return a negative number which is OK.

Then for troubleshooting, I wanted to Display some info at the top of the pages while I worked through these issues.

Next I needed to work out how to apply this to the site. What I needed to achieve is that what ever timezone I was in. I needed the date to return midnight of that day. (So if I was in Brisbane, It would need to return a unix time string equal to 29th June 2015 00:00:00, If I changed the time zone to Auckland it needed to adjust itself to the same time of 29th June 2015 00:00:00, Also if the time zone went into a negative zone i.e. GMT -10, it needed to return the same but for that timezone)

So while the date stays the same, the unix time string changes based on the offset of the time zone. The maths needed to make that calculation.

So I added the following code to one of the pages.

Firstly I take away the difference (be it positive or negative) from the record in the database. (So if you take a negative you add to the value). This then gives me a value that reflects the unix time string I need to accurately display the information.

Lastly I update the displaying record

Which sets the time stamp displayed correctly as I change through different time zones. After all that testing I can write the following function to process this regularly.