Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Strange date in account page


mylittlereddress

Recommended Posts

Posted

Hi,

 

I have noticed something strange and I don't think I have changed anything in this area, so not sure what it could be!

 

On the account page, in the overviews, the date for all the orders is reading as 01-01-1970. If I look at any of the oders I get the correct date that the order was placed and if I change the coding from

<td class="main" width="80"><?php echo tep_date_short($orders['date_purchased']); ?></td>

to

<td class="main" width="80"><?php echo tep_date_long($orders['date_purchased']); ?></td>

then I get the correct date the order was placed.

 

I have noticed there is a work around in includes/functions/general to allow numbers before 01-01-1970. Does anyone think this may be what is causing the date problem?

 

Coding for includes/functions/general

// Output a raw date string in the selected locale date format
// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers
 function tep_date_short($raw_date) {
   if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return false;

   $year = substr($raw_date, 0, 4);
   $month = (int)substr($raw_date, 5, 2);
   $day = (int)substr($raw_date, 8, 2);
   $hour = (int)substr($raw_date, 11, 2);
   $minute = (int)substr($raw_date, 14, 2);
   $second = (int)substr($raw_date, 17, 2);

   if (@date('Y', mktime($hour, $minute, $second, $day, $month, $year)) == $year) {
     return date(DATE_FORMAT, mktime($hour, $minute, $second, $day, $month, $year));
   } else {
     return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $day, $month, 2037)));
   }
 }

 

Does anyone have any ideas please??

 

Thank you

 

Ali

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...