francis Posted December 9, 2002 Posted December 9, 2002 I have created a new date field for products and have it displaying on the products details list as well as the product_info.php detailed page. However, the date format is currently showing as yyyy-mm-dd. In english.php I have set the date formats to: 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'); and left the raw date code as follows: 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); } } Can anyone tell me what I need to do to get the site to show the new date field as dd-mm-yyyy or d-m-y? Thanks
sw45859 Posted December 9, 2002 Posted December 9, 2002 define('DATE_FORMAT_SHORT', '%m/%d/%Y'); // this is used for strftime() define('DATE_FORMAT_LONG', '%m/%d/%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'); that will return m/d/yyyy define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // this is used for strftime() define('DATE_FORMAT_LONG', '%d/%m/%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'); that will return d/m/yyyy <?php echo strftime(DATE_FORMAT_LONG); ?> will return the values specified above if this doesn't help let me know
francis Posted December 9, 2002 Author Posted December 9, 2002 Unfortunately that hasn't worked. I think the answer must lie in the formatting around the actual code. Here is a copy of the new code in Includes-->Modules-->products_listing.php case 'PRODUCT_LIST_NEWDATE': $lc_text = '' . $listing_values['products_newdate'] . ' '; break; The code works, as the date shows up, but in the format yyyy-mm-dd. What code would I put around this code to make it change to dd/mm/yyyy?
Guest Posted December 10, 2002 Posted December 10, 2002 define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // this is used for strftime() define('DATE_FORMAT_LONG', '%d/%m/%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'); that will return d/m/yyyy Actually, there's a slight prob there. The 'DATE_FORMAT' define hasn't been changed, that could be francis' problem. Try this: define('DATE_FORMAT_SHORT', '%d/%m/%Y'); // this is used for strftime() define('DATE_FORMAT_LONG', '%d/%m/%Y'); // this is used for strftime() define('DATE_FORMAT', 'd/m/Y'); // this is used for date() <===== note the change define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S'); case 'PRODUCT_LIST_NEWDATE': $lc_text = '' . $listing_values['products_newdate'] . ' '; break; The code works, as the date shows up, but in the format yyyy-mm-dd. What code would I put around this code to make it change to dd/mm/yyyy? Okay, the dates are showing up in 'yyyy-mm-dd' format because that is how MySQL stores dates internally. Try changing the code you mentioned to: case 'PRODUCT_LIST_NEWDATE': $lc_text = '' . date(DATE_FORMAT, strtotime($listing_values['products_newdate'])) . ' '; break; IMHO it should all be handled automatically by the database abstraction layer. meh.
francis Posted December 11, 2002 Author Posted December 11, 2002 That was exactly what I needed to do. It now works a treat. Thanks to everyone.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.