Jeff VIP
Total posts: 745
17 Mar 2016 12:12

Hi,

My site is hosted by Siteground where the Server Time is SGT(+8) Asia/Singapore. The Server Time Zone in Joomla's Global Configuration is set to Adelaide (+10:30).

I have noticed that subscriptions start/end dates are saved in SGT time in the database, but on the site 10:30 hours are added instead of 2:30 hours (10:30-8=2:30 ) resulting in some subscriptions starting the next day.

I have edited a normal Joomla article and the modified time was saved in GMT(+0) time, which I think is correct timezone to store dates.

Last Modified: 19 Dec 2024


hakana VIP
Total posts: 425
18 Mar 2016 20:57

I think what you state is a server based Joomla issue, not a component issue. What happens when you post an article? Are the dates correct then?


Jeff VIP
Total posts: 745
21 Mar 2016 00:12

hakana I think what you state is a server based Joomla issue, not a component issue.

Joomla has no issues what so ever with my settings.

hakana What happens when you post an article? Are the dates correct then?

Yes. Articles are saved in UTC/GMT time in the database.

I spend 2 days checking and double checking this issue with phpMyAdmin, The World Clock – Time Zone Converter and displaying dates in different formats . My findings: Emerald is saving dates not in UTC time but in SGT time.


Sergey
Total posts: 13,748
23 Mar 2016 02:45

This is how I add create date to subscription

$db->setQuery("SELECT FROM_UNIXTIME($start)");
$this->ctime = $db->loadResult();

and this is how it is done in com_content

$date = JFactory::getDate();
$this->created = $date->toSql();

Emerald takes time from Mysql and Joomla from PHP.

Why? because we had a lot of problems with time in the past. Different settings. Many people do not understand Time Zone setting in Joomla and use it wrong. So there become a difference between PHP and MySQL time and when in the query we check access to sunscription we use WHERE extime >= NOW() we get wrong result.

What we did is, create time from MySQL and when we compare and check in MySQL query we always get correct result.

I can only suggest you to set Joomla TimeZone setting right. It is not exactly TimeZone. It is more Time offset. I mean Joomla think that your server time is UTC and TimeSone setting just add offset to that time. If your server time alreade +5GMT for example and you set Joomla TimeZone +5 then you get +10 at the end.


Jeff VIP
Total posts: 745
23 Mar 2016 06:44

Thanks Sergey for explaining.

Changing the Joomla TimeZone would affect the time display of other components too, wouldn't it? So I don't think this is a solution to my problem.

Strangely, Emerald doesn't respect the Joomla TimeZone when it comes to displaying dates. For example, in the Subscription Confirmation Email, the Start and End date are displayed in the MySQL TimeZone, which is very confusing for the end user. The same is true for the Subscription History page and the Sales page.

I think I can adjust the date output via template overrides:

$cdate = new DateTime($item->ctime, new DateTimeZone('SGT'));                                
$cdate->setTimezone(new DateTimeZone('Australia/Adelaide'));
echo $cdate->format('d/m/Y H:i:s T');

I'm not sure how to do this for the emails, though.


Sergey
Total posts: 13,748
23 Mar 2016 08:42

May be I have to add separate timezone parameter to Emerald. Or you just make sure your PHP and MySQL in the sime timesone. Or mysql NOW() and php date('Y-n-в H:i:s') are equal.


Jeff VIP
Total posts: 745
23 Mar 2016 09:57

Sergey May be I have to add separate timezone parameter to Emerald.

That would be ideal, since Emerald has a non Joomls standard way of storing dates. People without the TimeZone issue could leave the parameter empty and I could set a Timezone offset.

Sergey Or you just make sure your PHP and MySQL in the sime timesone.

Already done that through php.ini but this doesn't affect Emerald's time display

Sergey Or mysql NOW() and php date('Y-n-в H:i:s') are equal..

Huh?


Sergey
Total posts: 13,748
23 Mar 2016 14:15

I am waiting for you in skype.


pepperstreet VIP
Total posts: 3,837
23 Mar 2016 16:24

Very interesting discussion and important issue.
Screams for a docs article with usecase examples and tips.

Sorry, I always need a "picture" to get my head around things ;)


hakana VIP
Total posts: 425
23 Mar 2016 22:36

We have discussed this issue with Sergey before and he fixed the problem. And I checked it and never saw an issue since then. I don't understand how this issue came up again.

Please find the old topic here:
www.mintjoomla.com/support/community-forum/user-item/3923-hakana/52-emerald-9/4616-wrong-sales-time-in-admin-area.html


Jeff VIP
Total posts: 745
24 Mar 2016 00:55

hakana I don't understand how this issue came up again.

Do you have this issue again on your website?


Jeff VIP
Total posts: 745
27 Mar 2016 01:03

Sergey has added the option to insert [START+0] in the email template to output the date acoording to the Joomla TimeZone settings. All other dates can be manipulated through the templates. In short: Emerald still saves AND outputs dates in the MySQL timezone but the output can now be adjusted in the templates as well in the emails.


hyvyr
Total posts: 1
09 May 2022 18:21

Lab tests have shown that under intense pressure our cerebrums look for a fitting https://survivalhacks.co/beginners-guide-to-fishing-hunting-and-trapping-for-survival/ reaction and in some cases pick some unacceptable one. It is actually similar to deer that freeze in the headlights of a vehicle.


xywopu
Total posts: 1
16 Sep 2022 14:06

The quantity of individuals that are thinking about endeavour vocation preparing endeavours keeps on ascending with every day. A great many people confronting this thought are just centred around having the option to ensure that their abilities are attractive and that they can get a new line of work upon fulfilment of http://knowledgestech.com/ any educational experience where they set out upon.


lily167
Total posts: 14
25 Nov 2022 08:22

This is an excellent article. This is, in my opinion, one of the best posts ever written. Your work is excellent and inspiring. Thank you very much. build now gg


Juan34
Total posts: 2
07 Dec 2022 21:46

There are many different calculators on the market, but the best one is definitely the calculadora alicia . It has all the features you could possibly need in a calculator, and then some.


feqetud
Total posts: 1
05 Jul 2023 14:03

Require every one of your long periods of involvement, take a gander at every one of the inquiries you get posed digital marketing by your clients, and transform that into content across the different digital channels.


michaelarrington
Total posts: 3
04 Oct 2023 03:08

It seems like you have identified a timezone configuration issue in your Joomla website, and you're right in thinking that storing dates and times in GMT (+0) is a good practice for consistency io games


emmaagro
Total posts: 1
24 Nov 2023 10:14

I would suggest using the TimeZones component and using the action ConvertFromTimeZone (converts datetime from source time zone to destination time zone) when ...Your local time is your system time. Check the timezone in your operating system. The server time you are referring is according to the timezone in your server configuration files.The ToLocalTime method converts a DateTime value from UTC to local time. To convert the time in any designated time zone to local time, use the TimeZoneInfo. Core Ball ConvertTime method. The value returned by the conversion is a DateTime whose Kind property always returns Local.The safest way to make this test reliable and work all around the world is to use a date in your local time zone. You'll not use timestamps to set initial dates anymore. We can enhance the previous rule about timestamps: Rule #2 : String dates are suitable for display using the user's time zone and computations. To convert 18:00 UTC (6:00 p.m.) into your local time, subtract 6 hours, to get 12 noon CST. During daylight saving (summer) time, you would only subtract 5 hours, so 18:00 UTC would convert to 1:00 p.m CDT. Note that the U.S. uses a 12-hour format with a.m. and p.m. Other countries use 24-hour time.


BrielSanders
Total posts: 2
16 Nov 2024 17:51

To fix the issue with timezones in Joomla, ensure all database timestamps are stored in UTC for consistency. Adjust the "Server Time Zone" in Joomla’s Global Configuration to UTC and manage polytrack user-facing times using profile or display settings. This approach minimizes discrepancies between stored and displayed times.


KianHill
Total posts: 1
19 Dec 2024 12:05

Your subscription system appears to store dates in SGT (+8) instead of GMT (UTC), which conflicts with Joomla's global time zone settings. This causes incorrect time calculations, leading to toca life world subscriptions starting on the wrong date. To resolve this, ensure that the subscription system stores dates in UTC, aligning with Joomla's standards, and handles time zone conversions only for display purposes.

Powered by Cobalt