Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Swedish date format


Mavin

Recommended Posts

Posted

I have some problems with the date format on the site.

 

In US and many countries they specify the date in the format mm/dd/yyyy but in sweden we use yyyy-dd-mm nad i have tried almost anythnig but i can?t get it to work with that format or as mather a fact i can?t define it to work that way. Anyone who knows what to change to get i to work in that format.

Posted

In the languages file there are routines that handle date format.

 

In english.php under catalog/includes/languages you will find this:

 

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');

 

I guess you can figure out what to change here in your swedish.php.

 

If not, please tell us and we will try to help.

You can't have everything. That's why trains have difficulty crossing oceans, and hippos did not adapt to fly. -- from the OpenBSD mailinglist.

Posted

This is how i have configured in my swedish.php

 

setlocale(LC_TIME, 'sv_SE.ISO_8859-1');



define('DATE_FORMAT_SHORT', '%Y-%m-%d');  

define('DATE_FORMAT_LONG', '%A %d %B, %Y'); 

define('DATE_FORMAT', 'Y-m-d'); // this is used for date()

define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');

 

But it won?t work when i try to edit my account for example

Posted

This is how I've done it for dutch (also dd/mm/yyyy).

But this also doesn't work.

If I make a new account, I need to enter it starting with month, and that's not what I want.

Please help!

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');

Posted

Try with the german laguage. It works. Take the german.php as a starting point.

 

Oops. I just noticed the problem.

 

You must also adjust the tep_date_raw function in the language file.

 

Again - use the german.php as an example. At least for the dutch format it will work.

 

HTH

You can't have everything. That's why trains have difficulty crossing oceans, and hippos did not adapt to fly. -- from the OpenBSD mailinglist.

Posted

Please can?t you just help me with this tep_date_raw i don?t understand anything of it! i won?t it in swedish format yyyy-mm-dd

Posted
Please can?t you just help me with this tep_date_raw  i don?t understand anything of it! i won?t it in swedish format yyyy-mm-dd

 

Why noy do it the easy way!!!

 

http://telia.dl.sourceforge.net/sourceforg...sh-pr2.1.tar.gz

 

That is the swedish language pack for 2.1 look at the date formats in the svenska.php file :)

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)

Posted
Please can?t you just help me with this tep_date_raw  i don?t understand anything of it! i won?t it in swedish format yyyy-mm-dd

 

Try:

 

function tep_date_raw($date, $reverse = false) {

 if ($reverse) {

    return substr($date, 6, 4) . substr($date, 3, 2) . substr($date, 0, 2);

 } else {

  return substr($date, 0, 2) . substr($date, 3, 2) . substr($date, 6, 4);

 }

}

 

Not tested, not even well-thought, just the first try as I am running out of time to catch the train.

You can't have everything. That's why trains have difficulty crossing oceans, and hippos did not adapt to fly. -- from the OpenBSD mailinglist.

  • 2 weeks later...
Posted

that didn?t work either s? wath is it with this system, i?m getting realy tired... :?

 

Please help!

  • 2 weeks later...
Posted

any solution to this yet?

 

noticed that there seems to be something hardcoded in create_account_process.php in the catalog root.

 

if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4))) {

 

not sure what it is though. One thing that is certain though is that it does not matter what you enter in the swedish.php, the create account process always seems to want the english date.

 

Same goes for the advanced search function which also freaks out.

  • 2 weeks later...
Posted

Try changing the substr parameters in the function tep_date_raw in the file includes/languages/svenska.php.

 

This worked for me: :)

 

function tep_date_raw($date, $reverse = false) {

if ($reverse) {

return substr($date, 8, 2) . substr($date, 5, 2) . substr($date, 0, 4);

} else {

return substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2);

}

}

  • 2 months later...
Posted

Thought I could post my answer for it:)

 

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');



////

// Return date in raw format

// $date should be in format mm/dd/yyyy

// raw date is in format YYYYMMDD, or DDMMYYYY

function tep_date_raw($date, $reverse = false) { 

if ($reverse) { 

return substr($date, 8, 2) . substr($date, 5, 2) . substr($date, 0, 4); 

} else { 

return substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2); 

} 

}

 

This changes made in swedish.php

 

/Fred :D

  • 3 months later...
Posted

Thanks Fred!

 

One question, does it show the right date on the footer bar

1731 sidvisningar sedan Tuesday 22 April, 2003 ?

 

I cant seem to get that bit to work :(

 

 

/Anneli

Posted

Me again!

 

@setlocale('LC_TIME', 'swedish');

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');

 

////

// Return date in raw format

// $date should be in format mm/dd/yyyy

// raw date is in format YYYYMMDD, or DDMMYYYY

function tep_date_raw($date, $reverse = false) {

if ($reverse) {

return substr($date, 8, 2) . substr($date, 5, 2) . substr($date, 0, 4);

} else {

return substr($date, 0, 4) . substr($date, 5, 2) . substr($date, 8, 2);

}

}

 

This made it in my svenska.php file.

:D :D

 

/Anneli

  • 6 years later...

Archived

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

×
×
  • Create New...