Guest Posted June 20, 2004 Posted June 20, 2004 Hi there, I love osCommerce and the fact that it is contribution based etc. However, there seems to be very little support for some simple configuration issues. The issue I have regards date of birth formats. I live in Sweden and need the YYYY/MM/DD format instead of the MM/DD/YYYY or the DD/MM/YYYY formats. Now, I have scrawled the forums the whole day and seen all the replies to requests, and basically they dont work. Not only this, there seems to be zero information on the logic behind the formatting of the date of birth field. If at least osCommerce would explain all the variables which were involved in checking the date of birth field, we, the users, could then come up with a solution for formatting the date of birth field to how we would like it to be presented by the customer in the account creation screen. So for example, if I wanted it YYYY/MM/DD, I could tell easily how this format could be integrated into osCommerce. Does anyone know the solution? Has anyone from Sweden integrated this format into their site?? Or do I have to use the DD/MM/YYYY format by virtue of the fact that osCommerce makes this particular issue oversomplicated? many thanks, Luke Ray
AlanR Posted June 20, 2004 Posted June 20, 2004 The date format is in the primary language.php file (ie: includes/languages/english.php for english) 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'); Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)
Guest Posted June 21, 2004 Posted June 21, 2004 No, I have tried this. This is exactly what I mean...many people state that editing these variables is all that is involved, but it is not the case. I have even edited more variables than these with no luck!
Mark Evans Posted June 21, 2004 Posted June 21, 2004 Have you tried these settings setlocale(LC_TIME, 'sv_SE.ISO_8859-1'); define('DATE_FORMAT_SHORT', '%Y-%m-%d'); // this is used for strftime() define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime() define('DATE_FORMAT', 'Y-m-d'); // this is used for date() define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S'); Mark Evans osCommerce Monkey & Lead Guitarist for "Sparky + the Monkeys" (Album on sale in all good record shops) --------------------------------------- Software is like sex: It's better when it's free. (Linus Torvalds)
Guest Posted June 21, 2004 Posted June 21, 2004 Hi Mark, Yes, I have tried all of these settings. The funny thing is that I can get MM/DD/YYYY and DD/MM/YYYY to work, but when it comes to logically modifying the code to work with YYYY/MM/DD, everything goes wrong I get an error message come up that there is an error on line 80 of the create_account.php script. So basically, there is a problem somewhere else which has nothing to do with the suggestion you come up with. It seems to be deeper rooted than this. I can see from the live sites in Sweden that they have completely given up on this issue and decided to go for the DD/MM/YYYY format. However, everyone here thinks in the YYYY/MM/DD format and I would like for there to be no mistakes. Does anyone know the solution for formatting the script so that the year comes first?
vasttech Posted June 21, 2004 Posted June 21, 2004 The problem is that the way osCommerce is currently coded it can only accept mm/dd/yyyy and dd/mm/yyyy. You would need to edit any code that checks date entry and inserts into the database to accept the yyyy/mm/dd format. I am not sure where all the code is exactly, you would have to play around. For starters, line 80 of create_account.php has some. I am sure that the general.php file also has some in it. Pretty much any page where dates are accepted, checked, or put in the database. The code change would not be hard, you would just have to change the order in which it reads the date string. osCommerce Knowledge Base osCommerce Documentation Contributions
Guest Posted June 21, 2004 Posted June 21, 2004 Hi Jeff, I have in fact sussed some code, in particular that in the language files (eg. english.php): - function tep_date_raw($date, $reverse = false) { if ($reverse) { return substr($date, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4); } else { return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2); so as to accept the format I want. However, when it comes to knowing to to modify the following: - if (ACCOUNT_DOB == 'true') { if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false) { $error = true; I dont know where to start. Do you know which relates to the year, the month and the date? If you do, then I would love to know as I can then modify other files with these values. Cheers, Luke Ray
kwikone Posted June 21, 2004 Posted June 21, 2004 I have in fact sussed some code, in particular that in the language files (eg. english.php): - function tep_date_raw($date, $reverse = false) { if ($reverse) { return substr($date, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4); } else { return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2); so as to accept the format I want. However, when it comes to knowing to to modify the following: - if (ACCOUNT_DOB == 'true') { if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false) { $error = true; I dont know where to start. Do you know which relates to the year, the month and the date? If you do, then I would love to know as I can then modify other files with these values. Cheers, Luke Ray Actually, from what you gave it should be simple... Just take the if (ACCOUNT_DOB == 'true') { if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false) { $error = true; And change it to read if (ACCOUNT_DOB == 'true') { if (checkdate(tep_date_raw($dob), TRUE) == false) { $error = true; This will check return the Raw date in YYYYMMDD format So, everywhere there is a checkdate call; just add the , TRUE to the call parameter and you have the date in the YYYYMMDD format which you can then format and you won't get the formatting problems you described. Kerry
Guest Posted June 21, 2004 Posted June 21, 2004 I'll give this a try Kerry. If it works then Ill try to make a contribution out of it!!!
Matrix7 Posted August 10, 2004 Posted August 10, 2004 Guys, I'm having similar problems with my osCommerce site. Can someone please explain how I can set osCommerce to accept date of birth in DD/MM/YYYY format? It is apparent that it can be done, I just haven't figured it yet. Many thanks.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.