Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 25. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  strftime() and date() display problem -> one day earlier

phpMyEdit General     strftime() and date() display problem -> one day earlier
Odoslať novú tému   Odpovedať na tému    
 
rm     Založený: 30.01.2009   Príspevky: 2  
Príspevok Zaslal: 2009-01-30 19:10
Návrat hore  Odpovedať s citátom     

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.


Naposledy upravil rm dňa 2009-02-02 14:29, celkom upravené 1 krát

 
rm     Založený: 30.01.2009   Príspevky: 2  
Príspevok Zaslal: 2009-02-02 11:47
Návrat hore  Odpovedať s citátom     

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     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-02-04 14:04
Návrat hore  Odpovedať s citátom     

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.

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov