Re: Now available: AJAX/PHP multilingual website templates
Posted: Tue 15 Mar 2011 4:12 pm
limitation of strotime.Handle dates with / in m/d/y format.probably thats the reason.
Support forum for Cumulus weather station software
https://cumulus.hosiene.co.uk/
Confirmed it works.gemini06720 wrote:Just noticed that on my main page...kinder wrote:Any guess why the next update time shows always next update at 2:01?![]()
I checked the value of the variable '$timeofnextupdate' - it seems to always give me 16:10, no matter what time the next update should be.
I then checked how the the variable '$timeofnextupdate' was calculated/created (in the 'CU-defs.php' script):It first converts (parse) the current date and the current time into a Unix timestamp and then adds the time interval (in minutes, as setup in Cumulus) multiplied by 60 (so the time interval is really in seconds).Code: Select all
$timeofnextupdate = date('H:i',strtotime($date.' '.$time)+$WX['interval']*60);
But, for some reasons, the PHP function 'strtotime' refuses to convert (parse) the date in this format '15/03/2011' !
So, what I have done to eliminate the error (or lack of proper data) was to add the following line directly into my 'ajax-dashboard.php' script, just before the start of the display of the weather data:I do not know why it is happening ... Ken is probably the only one that will be able to provide an explanation...Code: Select all
$timeofnextupdate = date('H:i',strtotime($time)+$WX['interval']*60);
Code: Select all
$SITE['realtimefile'] = 'http://meteoestremera.es/meteoestremera/meteo/realtime.txt';
Code: Select all
$SITE['realtimefile'] = '../meteoestremera/meteo/realtime.txt';
Ah, yes... it's that 'PHP is confused by European-style-dates' issue. The default for PHP is to use mm/dd/yyyy format if no Locale setting is done. I'd not done any setlocale() calls to force the PHP into handling the issue directly (dd/mm/yyyy) since the various setlocale() strings are quite varied across platforms. For example, to set Dutch format, I'd had to use something likekinder wrote:Confirmed it works.gemini06720 wrote:Just noticed that on my main page...kinder wrote:Any guess why the next update time shows always next update at 2:01?![]()
I checked the value of the variable '$timeofnextupdate' - it seems to always give me 16:10, no matter what time the next update should be.
I then checked how the the variable '$timeofnextupdate' was calculated/created (in the 'CU-defs.php' script):It first converts (parse) the current date and the current time into a Unix timestamp and then adds the time interval (in minutes, as setup in Cumulus) multiplied by 60 (so the time interval is really in seconds).Code: Select all
$timeofnextupdate = date('H:i',strtotime($date.' '.$time)+$WX['interval']*60);
But, for some reasons, the PHP function 'strtotime' refuses to convert (parse) the date in this format '15/03/2011' !
So, what I have done to eliminate the error (or lack of proper data) was to add the following line directly into my 'ajax-dashboard.php' script, just before the start of the display of the weather data:I do not know why it is happening ... Ken is probably the only one that will be able to provide an explanation...Code: Select all
$timeofnextupdate = date('H:i',strtotime($time)+$WX['interval']*60);
Probably Ken should add that in next version to ensure that strtotime works in every case as it should be.
Code: Select all
$locale = setlocale(LC_TIME,'nl_NL.ISO8859-1', 'nld_nld', 'nl_NL','nl_NLD',"nld","NLD", "dutch", "holland", "netherlands");
Code: Select all
$timeofnextupdate = date('H:i',strtotime($time)+$WX['interval']*60);Code: Select all
$SITE['WDdateMDY'] = false;Well the WDdateMDY = false because cumulus running on a pc with greek locale and also reports dates and times in euro format.Is it wrong?I think theis a good idea (avoids the issue) and will work it in to an update.Code: Select all
$timeofnextupdate = date('H:i',strtotime($time)+$WX['interval']*60);
Also, check your Settings.php entry forthat instructs the date functions to process the dates from Cumulus as M/D/Y (for =true) or as D/M/Y (for =false) .. if it's set incorrectly, all bets are offCode: Select all
$SITE['WDdateMDY'] = false;
Best regards,
Ken
The 'strtotime' function is supposed to (as written in the documentation) "...parse about any English textual datetime description into a Unix time...".kinder wrote:limitation of strotime.Handle dates with / in m/d/y format.probably thats the reason.
Ken, just to be sure I understand clearly the purposes/results of the '$SITE['WDdateMDY']' variable:saratogaWX wrote:Also, check your Settings.php entry forthat instructs the date functions to process the dates from Cumulus as M/D/Y (for =true) or as D/M/Y (for =false) .. if it's set incorrectly, all bets are offCode: Select all
$SITE['WDdateMDY'] = false;![]()
Is PHP not a global project with people from almost every countries of the world participating - why would one PHP function not be able to handle the European-style date formats without having to go through additional setups...saratogaWX wrote:...Ah, yes... it's that 'PHP is confused by European-style-dates' issue...
Link: strtotime() functionNote:
Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.
To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.