Zen Cart Logo
Forums / Bug Reports / [Done v1.6.0] PHP Fatal error: Undefined constant 'PHP_DATE_TIME_FORMAT'

[Done v1.6.0] PHP Fatal error: Undefined constant 'PHP_DATE_TIME_FORMAT'

Locked

Views: 2,787

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
9 Jul 2012, 12:18 PM
#1
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,284
Plugin Contributions:
37

[Done v1.6.0] PHP Fatal error: Undefined constant 'PHP_DATE_TIME_FORMAT'

We found that the root issue is that older versions of php would silently ignore undefined constants. Php 5.3 enforces this as undefined constants should not be used. Furthermore, since php 5.3, constants can only be defined using the define() function.

PHP_DATE_TIME_FORMAT is specific to OS Commerce and any derivatives (including zen cart). So, unfortunately, it is not something that we can set in php.ini.

To use it with php 5.3, add the following line to the includes/languages/your_template/english.php. Using php 5.2 simply ignores the problem of the undefined constant.

// look in your $PATH_LOCALE/locale directory for available locales..
  @setlocale(LC_TIME, 'en_US');
  define('DATE_FORMAT_SHORT', '%m/%d/%Y');  // this is used for strftime()
  define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()
  define('DATE_FORMAT', 'm/d/Y'); // this is used for date()
  define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');
  [B]define('PHP_DATE_TIME_FORMAT', 'd/m/Y H:i:s');[/B]
10 Jul 2012, 2:59 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: [Done v1.6.0] PHP Fatal error: Undefined constant 'PHP_DATE_TIME_FORMAT'

Oddly enough, when I search the v1.5.0 code for PHP_DATE_TIME_FORMAT the only place I see it is a define() statement in the admin english.php. But never used in core code anyplace.

Where are you seeing the constant actually used, that it's causing an error?

10 Jul 2012, 3:04 PM
#3
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,284
Plugin Contributions:
37

Re: [Done v1.6.0] PHP Fatal error: Undefined constant 'PHP_DATE_TIME_FORMAT'

It's not been an issue for Zen Cart itself, but we have seen the issue using other software such as feed generators and reporting mods that cannot determine the format because it is not defined. Adding it to the catalog english defines completely resolves the issue.

10 Jul 2012, 3:15 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: [Done v1.6.0] PHP Fatal error: Undefined constant 'PHP_DATE_TIME_FORMAT'

Okay, so the "bug" is that these external addons are making assumptions about this unused-by-Zen-Cart constant being defined.

Our fix in core is likely to simply remove the unused constant. Addons should update their code to define the required constant for themselves if it isn't found.

10 Jul 2012, 5:10 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: [Done v1.6.0] PHP Fatal error: Undefined constant 'PHP_DATE_TIME_FORMAT'

Clarification: The constant will be removed in v1.6.0