Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Database and date format

    Is there any way I could change the date format in the database file?

    I'm not able to import the orders to book keeping as long as the dates are American - I need them to be dd.mm.yyyy for the file to be read and accepted by the Norwegian system.

    Please help?

  2. #2
    Join Date
    Nov 2007
    Location
    Woodbine, Georgia, United States
    Posts
    4,009
    Plugin Contributions
    61

    Default Re: Database and date format

    PRO-Webs, Inc. :: Recent Zen Cart Projects :: Zen Cart SEO – 12 Steps to Success
    **I answer questions in the forum, private messages are NOT answered. You are welcome to contact us via our website for professional engagements.

  3. #3
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Re: Database and date format

    Oh wow, exactly what I needed! Thank you so much, I will try it out! :)

  4. #4
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Re: Database and date format

    This doesn't work... Is the tutorial based on an old version or something? My file doesn't look like that, and I can't find what I'm supposed to be replacing. Although it's no doubt the file is right, it seems to do the same thing just not in the coding from the tutorial.

  5. #5
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,262
    Plugin Contributions
    3

    Default Re: Database and date format

    Quote Originally Posted by Unicorn View Post
    This doesn't work... Is the tutorial based on an old version or something? My file doesn't look like that, and I can't find what I'm supposed to be replacing. Although it's no doubt the file is right, it seems to do the same thing just not in the coding from the tutorial.
    If the file (or the part) you are editing does not look like file in the tutorial, then you could be looking at the wrong file.

    There is nothing wrong with the advice / method in the tutorial, nor in the files it relates to, so try again... If you really battle, come back and tell us the FILE NAME(S) you are looking at and (if possible) why it all looks like pea soup.
    19 years a Zencart User

  6. #6
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Re: Database and date format

    OK, let's see...

    There was no includes/languages/<YOUR_TEMPLATE>/<YOUR_LANGUAGE>.php, so I did what it said and copied includes/languages/<YOUR_LANGUAGE>.php. Had to make the languages/yourtemplate though, that was not there either.

    When I open the norwegian.php, I'm supposed to find:

    @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');
    With me, locale is already set:

    // look in your $PATH_LOCALE/locale directory for available locales..
    // on RedHat try 'no_NO'
    // on FreeBSD try 'no_NO.ISO_8859-1'
    // on Windows try 'no', 'nor' or 'norwegian'
    setlocale(LC_TIME, 'no_NO.ISO8859-1', 'nb_NO.ISO-8859-1', 'no', 'nb', 'no-NO', 'nb-NO', 'no_NO', 'nb_NO', 'nor', 'norwegian', 'bokmal');
    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');
    So, moving along to the next step:

    // Return date in raw format

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

    // raw date is in format YYYYMMDD, or DDMMYYYY

    if (!function_exists('zen_date_raw')) {

    function zen_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);

    }

    }

    }
    I get lost... What I have, is:

    */
    if (!function_exists('zen_date_raw')) {
    function zen_date_raw($date)
    {
    $date = strtolower($date);

    // get a list of abbreviated and full month names
    for ($i=1; $i < 13; $i++)
    {
    $month_abbr[$i] = strtolower(strftime('%b',strtotime("2000-$i-1")));
    $month_name[$i] = strtolower(strftime('%B',strtotime("2000-$i-1")));
    }

    // if DATE_FORMAT has not been defined, find it automatically by checking against the localised format
    if (!defined('DATE_FORMAT'))
    {
    $local_format = strftime('%x', strtotime('2000-1-3'));

    $local_format = str_replace(array('2000', '00', '01', '1', '03', '3'), array('Y', 'y', 'm', 'n', 'd', 'j'), $local_format);
    $local_format = str_replace($month_name, 'F', $local_format);
    $local_format = str_replace($month_abbr, 'M', $local_format);
    define('DATE_FORMAT', $local_format);
    }

    // look for a full month name in the date string
    foreach ($month_name as $key => $val)
    {
    $strpos = strpos($date, $val);
    if ($strpos !== false)
    {
    // insert month number in front of the string where the month name was found
    $date = substr_replace($date, $key, $strpos, 0);
    break;
    }
    }

    if ($strpos === false)
    // a full month name was not found in the date string, now look for abbreviations
    {
    // find the first occurance of a month abbreviation
    // this is necessary since there's a chance one abbreviation is part of another month name. thus, if the customer is entering the full month name, he would not get the correct month if we didn't do this
    for ($i=1; $i < 13; $i++)
    {
    $month_strpos[$i] = strpos($date, $month_abbr[$i]);
    if ($month_strpos[$i] !== false && (!isset($first_case) || $month_strpos[$i] < $first_case))
    {
    $first_case = $month_strpos[$i];
    $m = $i;
    }
    }
    if (isset($m) && isset($first_case))
    {
    // insert month number in front of the string where the month abbreviation was found
    $date = substr_replace($date, $m, $first_case, 0);
    }
    }

    // remove all non-numeric characters
    $date = preg_replace('/[^0-9]/', '', $date);

    // remove all characters except those allowed from the constant DATE_FORMAT
    $dformat = preg_replace('/[^YyFMmndj]/', '', DATE_FORMAT);

    // Define regex for day, month and year
    $dd = '([0-2][1-9]|[1-3][0-1]|[1-9])';
    if (isset($m) && isset($first_case))
    {
    $mm = '(' . $m . ')';
    }
    else
    {
    $mm = '(0?[1-9]|1[0-2])';
    }

    $yyyy = '((19|20)?[0-9]{2})';
    // Look at the set date format, and create the entire regex line as well as set the location where day, month and year is to be found for later reference
    if (preg_match('/(d|j)(F|M|m|n)(y|Y)/', $dformat))
    {
    $regexp = $dd . $mm . $yyyy;
    $d = '1';
    $m = '2';
    $y = '3';
    }
    elseif (preg_match('/(F|M|m|n)(d|j)(y|Y)/', $dformat))
    {
    $regexp = $mm . $dd . $yyyy;
    $d = '2';
    $m = '1';
    $y = '3';
    }
    elseif (preg_match('/(d|j)(y|Y)(F|M|m|n)/', $dformat))
    {
    $regexp = $dd . $yyyy . $mm;
    $d = '1';
    $m = '4';
    $y = '2';
    }
    elseif (preg_match('/(F|M|m|n)(y|Y)(d|j)/', $dformat))
    {
    $regexp = $mm . $yyyy . $dd;
    $d = '4';
    $m = '1';
    $y = '2';
    }
    elseif (preg_match('/(y|Y)(d|j)(F|M|m|n)/', $dformat))
    {
    $regexp = $yyyy . $dd . $mm;
    $d = '3';
    $m = '4';
    $y = '1';
    }
    else
    {
    $regexp = $yyyy . $mm . $dd;
    $d = '4';
    $m = '3';
    $y = '1';
    }

    // if this doesn't look like a valid date, return false
    if (!preg_match('/^' . $regexp . '$/', $date, $regs))
    {
    return false;
    }

    // If some values are too short, fix them
    // fix value of day
    if (strlen($regs[$d]) == '1')
    {
    $regs[$d] = '0' . $regs[$d];
    }
    // fix value of month
    if (strlen($regs[$m]) == '1')
    {
    $regs[$m] = '0' . $regs[$m];
    }
    // fix value of year. If year is less than or equal to the last 2 numbers of the current year, set century to 20
    if (strlen($regs[$y]) === 2)
    {
    if ($regs[$y] <= date('y'))
    {
    $regs[$y] = '20' . $regs[$y];
    }
    else
    {
    $regs[$y] = '19' . $regs[$y];
    }
    }

    // validate the date
    if (!checkdate($regs[$m], $regs[$d], $regs[$y]))
    {
    return false;
    }

    // return YYYYMMDD
    return $regs[$y] . $regs[$m] . $regs[$d];
    } // end function zen_date_raw()
    }


    And I'm puzzled... Where do I replace that bit?

 

 

Similar Threads

  1. v139h Coupon start and end date format
    By onetrack in forum General Questions
    Replies: 0
    Last Post: 9 Aug 2012, 07:56 AM
  2. Date Format and Name Titles
    By lau in forum Customization from the Admin
    Replies: 0
    Last Post: 2 Dec 2006, 05:44 PM
  3. date format in packingslip and invoice
    By etoile03 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 30 Nov 2006, 11:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR