Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Format the date for Australia


TB

Recommended Posts

I need to change the format of the date from the US format of: MM/DD/YY to DD/MM/YY or even DD-MMM-YY.

 

Can someone please let me know how I go about do this?

 

Thanks,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

with my LITTE php knowledge, I came up with:

 

<?php

  $my_time = mktime(0, 0, 0, 11,24,2002);



  $my_formatted_time = date("jS, F, Y", $my_time);



  echo ($my_formatted_time);

?>

 

^ = 24th, November, 2002

Link to comment
Share on other sites

$date = substr($date,8,2) . "/" . substr($date,5,2) . "/" . substr($date,0,4);

 

Should work OK, you'll need to set $date or change reference to it to the normal Osc date call - cannot remember it off the top of my head.

 

HTH

Link to comment
Share on other sites

Thanks for your input!

 

Which files do I edit to change the format of the date site wide?

Basically... I don't want to display the date as an 'echo' in one instance... but all dates on all pages (ie. expecting stock) is in the DD-MM-YY or DD-MMM-YY format.

 

Thanks,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

  • 2 weeks later...

Hi again all,

 

Just wondering if anyone knows where the key file reference to date formating is in osCommerce.

 

Is there just one location in a file that I need to change the format of the date to DD-MMM-YYYY to make the date format for the whole site change or does it need to be done in a few files.

 

If anyone knows, can you please post the code changes I need to make.

 

Cheers,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

I'm still trying to work this one out... and am quite surprised that it's not a standard admin feature.

 

I've attached my versions of english.php and create_account.php, there are other files that will need the same modifications also, though I will be able to do them once I find out where I'm going wrong with these ones.

 

When I go to create a new account, I think it's still looking for the old format of MM/DD/YYYY instead of the updated format of DD/MM/YYYY.

Can someone please let me know where I'm going wrong and what files and areas I need to modify.

 

My aim is to have my whole site running in DD/MM/YYYY.

 

Many thanks,

Tony

 

english.php

// look in your $PATH_LOCALE/locale directory for available locales..

// on RedHat try 'en_US'

// on FreeBSD try 'en_US.ISO_8859-1'

// on Windows try 'en', or 'English'

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

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



////

// 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, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4);

 } else {

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

 }

}

 

create_account.php

  if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {

   $error = true;

   $entry_lastname_error = true;

 } else {

   $entry_lastname_error = false;

 }



 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))) {

     $entry_date_of_birth_error = false;

   } else {

     $error = true;

     $entry_date_of_birth_error = true;

   }

 }



 if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {

   $error = true;

   $entry_email_address_error = true;

 } else {

   $entry_email_address_error = false;

 }

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

The /catalog/includes/langauges/english.php is the first 'code' in my previous posting.

 

I haven't done it correctly (or it's not working if I have) but I've changed the code to reflect what I think is dd/mm/yyyy.

 

When this is done correctly through /catalog/includes/langauges/english.php will it automatically change the 'checkdate' format for the forms so it looks for dd/mm/YYYY instead of mm/dd/YYYY or does this need to be done on each page individually?

 

Cheers,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

Thanks for the info David!

I love this forum! :D

 

I'll make the changes and see how I go... silly me... has gone and changed pretty much ALL references to the dates in a heaps of files... so it may take some searching since I didn't make notes of which files I edited! DOH! :roll:

 

On a side note... I had a look at your site and have seen that you provide search engine services.

Can you please Private Message me about the costs involved and varying qualities of search engines.

The Australian aviation market is my main concern if this helps.

 

Many thanks again,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...