Forums / General Questions / Changing Date Format in 1.54 to UK

Changing Date Format in 1.54 to UK

Started by nigelt74 on 23 Apr 2015, 8:42 AM · Views: 2,069

Results 1 to 6 of 6
23 Apr 2015, 8:42 AM
#1
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Changing Date Format in 1.54 to UK

First off, i have changed the date format from US to the UK version many many times in older versions of zencart

https://www.zen-cart.com/showthread.php?57548-How-do-I-change-the-Date-format

But in version 1.54 the specific block of code is slightly different and I don't really know why and what the effect of me changing it the way i used to would do

includes/languages/english.php

Old code

@setlocale(LC_TIME, 'en_US.ISO_8859-1');
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');

The new code

// look in your $PATH_LOCALE/locale directory for available locales..
  $locales = array('en_US', 'en_US.utf8', 'en', 'English_United States.1252');
  @setlocale(LC_TIME, $locales);
  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');

The last 4 lines are identical in both, not a problem,

however it is the conversion of the first line in the old code

@setlocale(LC_TIME, 'en_US.ISO_8859-1');

that becomes two lines in the newer code, how do I Anglicise that

$locales = array('en_US', 'en_US.utf8', 'en', 'English_United States.1252');
@setlocale(LC_TIME, $locales);

becomes what in English UK , and will the change to UTF8 effect anything if my database has been imported from an older version

Thanks

Webzings Design
Semi retired from Web Design

23 Apr 2015, 4:40 PM
#2
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,019
Plugin Contributions:
2

Re: Changing Date Format in 1.54 to UK

These are my settings. The first two lines are unchanged and I have not found any problems to date. I do not recall when I made these changes but have carried much the same settings through from 139h.

// look in your $PATH_LOCALE/locale directory for available locales..
  $locales = array('en_US', 'en_US.utf8', 'en', 'English_United States.1252');
  @setlocale(LC_TIME, $locales);
  define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // this is used for strftime()
  define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()
  define('DATE_FORMAT', 'd/m/Y'); // this is used for date()
  define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');
23 Apr 2015, 5:07 PM
#3
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Changing Date Format in 1.54 to UK

nigelt74:

...

$locales = array('en_US', 'en_US.utf8', 'en', 'English_United States.1252');
@setlocale(LC_TIME, $locales);

... becomes what in English UK ...

Depends on the server hosting your website and what locales are installed. Here are the typical ones for Linux / Windows servers... But if your server does not have support for ONE of these enabled, you may need to ask your hosting provider what locales are available for your use in PHP (or just use the US ones).

$locales = array('en_GB', 'en_GB.utf8', 'en', 'English_United Kingdom.1252');
@setlocale(LC_TIME, $locales);

NOTE: combine with what dw08gm posted.

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

19 Jul 2015, 4:06 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Changing Date Format in 1.54 to UK

Has anyone gotten the admin-level spiffyCal dates to get properly formatted when using a dd/mm/yyyy date format? I've applied all the other changes suggested in this thread as well as this (https://www.zen-cart.com/content.php?301-how-to-i-change-dates-from-us-format-to-dd-mm-yyyy) FAQ.

If, for example, I go to Catalog->Featured Products and display the entry for a product which is available on 30/05/2014 and ends on 24/06/2016, those dates are displayed properly in the calendar display but when I go to change the date, the calendar-entry defaults to the current month -- indicating that it's not "happy" with the date format.

If I choose a date from the calendar, the date displayed reverts to mm/dd/yyyy format which is also the format in which the data is posted back. The result is that 0000-00-00 is stored in the database because the date-formatting modifications create an invalid "raw" date, e.g. 20152406.

19 Jul 2015, 9:53 PM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Changing Date Format in 1.54 to UK

lat9:

Has anyone gotten the admin-level spiffyCal dates to get properly formatted when using a dd/mm/yyyy date format?

Although I don't recall ever changing this:

/admin/includes/javascript/spiffyCal/spiffyCal_v2_1.js

line#45 reads
this.defaultDateFormat="dd-MMM-yyyy"

I don't have the problem that you are describing, so perhaps this is something to check?

Also, I've just found /admin/includes/languages/english.php has a line that reads:
define('DATE_FORMAT_SPIFFYCAL', 'dd/MM/yyyy');

I suspect that this is the 'important' one.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

20 Jul 2015, 11:18 AM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Changing Date Format in 1.54 to UK

RodG:

Although I don't recall ever changing this:

/admin/includes/javascript/spiffyCal/spiffyCal_v2_1.js

line#45 reads
this.defaultDateFormat="dd-MMM-yyyy"

I don't have the problem that you are describing, so perhaps this is something to check?

Also, I've just found /admin/includes/languages/english.php has a line that reads:
define('DATE_FORMAT_SPIFFYCAL', 'dd/MM/yyyy');

I suspect that this is the 'important' one.

Cheers
RodG
Yep, it was that last one that did the trick! I thought I'd seen that define somewhere (after spending about an hour trolling through the javascript).