Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  strftime() and date() display problem -> one day earlier

phpMyEdit General     strftime() and date() display problem -> one day earlier
Post new topic   Reply to topic    
 
rm     Joined: 30 Jan 2009   Posts: 2  
Post Posted: 2009-01-30 19:10
Back to top  Reply with quote     

I wonder if anyone can provide any pointers as to why an underlying MySQL date should display in phpMyEdit with a "one day earlier" error ?

This only happens for some dates, and I have yet to establish whether the affected data was input via phpMyEdit or not.

This error can be seen using both of the following formatting settings :

'datemask' => 'D d/m/Y',

'strftimemask' => '%a %d/%m/%Y',

and for example will display an underlying database value of :

2009-04-04 as Fri 03/04/2009

Any help much appreciated.


Last edited by rm on 2009-02-02 14:29, edited 1 time in total

 
rm     Joined: 30 Jan 2009   Posts: 2  
Post Posted: 2009-02-02 11:47
Back to top  Reply with quote     

I've done a bit of digging into this one, and have come up with a workaround by hacking the phpMyEdit class.

See the comments in the code, I would welcome any comment, confirmation, or denial on this problem.

Watch for wrap ....

===============================
function cellDisplay($k, $row, $css) /* {{{ */
{
$escape = isset($this->fdd[$k]['escape']) ? $this->fdd[$k]['escape'] : true;
$key_rec = $row['qf'.$this->key_num];
if (@$this->fdd[$k]['datemask']) {
/*
2009 02 02 Ronnie MacGregor bugfix
There seems to be a problem with datemask and strftimemask whereby for some dates
only, the date that is displayed is one day earlier than that stored in the table.
The calculated field appended with "_timestamp" is created in the function
get_SQL_column_list(), and uses the MySQL function UNIX_TIMESTAMP(). It may be that
this function is the root of the problem, and may involve the difference between
UTC and the local time zone ..... yet to be proven.
As a workaround, we can avoid the use of this calculated "_timestamp" field, and
simply prepare the field value for "date()" or "strftime()" processing by using
strtotime() on the field value.
*/
// $value = intval($row["qf$k".'_timestamp']); // Original line ///////////////////
$value = strtotime($row["qf$k"]); ////////////// Ronnie's line ///////////////////
$value = $value ? @date($this->fdd[$k]['datemask'], $value) : '';
} else if (@$this->fdd[$k]['strftimemask']) {
/*
2009 02 02 Ronnie MacGregor bugfix
There seems to be a problem with datemask and strftimemask whereby for some dates
only, the date that is displayed is one day earlier than that stored in the table.
The calculated field appended with "_timestamp" is created in the function
get_SQL_column_list(), and uses the MySQL function UNIX_TIMESTAMP(). It may be that
this function is the root of the problem, and may involve the difference between
UTC and the local time zone ..... yet to be proven.
As a workaround, we can avoid the use of this calculated "_timestamp" field, and
simply prepare the field value for "date()" or "strftime()" processing by using
strtotime() on the field value.
*/
// $value = intval($row["qf$k".'_timestamp']); // Original line ///////////////////
$value = strtotime($row["qf$k"]); ////////////// Ronnie's line ///////////////////
$value = $value ? @strftime($this->fdd[$k]['strftimemask'], $value) : '';

===============================

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2009-02-04 14:04
Back to top  Reply with quote     

It looks like PHP's strftime() function doesn't play well with Sun Solaris servers, in case that is the type of server you are using. There are also some notes at http://us.php.net/strftime about locale settings and various character sets (or lack thereof) which cause the reported problem.

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy