Change the output format of Date/Time attribute

Permalink
While adding the Date/Time attribute and setting the Date/Time Options as date only, the output i'm getting is like "Date: 2015-03-06 00:00:00". How to remove the time being printed. please help. I have another field for specific times. please help.

dhinesh
View Replies:
hutman replied on at Permalink Reply
hutman
Are you using 5.6 or 5.7?
What is the current code you are using to output the date?
dhinesh replied on at Permalink Reply
dhinesh
Thanks for the reply hutman

I'm using 5.6.
it is printed in the receipt mail of core commerce. i'm new to concrete5 and i dont know how to change.
the code which print the details are
foreach($products as $i => $product) {
   $keyValues = array();
   foreach($product['attributes'] as $key => $attr) {
      $keyValues[] = "{$key}: {$attr}";
   }
   $prod_img = '-';
   if($product['object']) {
      $img_obj = $product['object']->getProductThumbnailImageObject();
      if(is_object($img_obj)) {
         $img_url = $img_obj->getRelativePath();
         if($img_url) {
            $prod_img = '<img src="'.BASE_URL.$img_url.'" width="70" />';
         }
      }
   }


or

is there any way i can modify the format of attribute in the above code itself.
can you please help me with this?
Thanks
studio108 replied on at Permalink Reply
studio108
Have you looked at possibly changing the date and time formats using the config/site.php

It is discussed here and quite a few other places.

http://www.concrete5.org/community/forums/installation/timeformat-i...
dhinesh replied on at Permalink Reply
dhinesh
Thanks studio108,

But i've tried all these things, yet not succeded!
hutman replied on at Permalink Reply
hutman
Can you provide a screen shot of which date on the receipt you are talking about, what version of the eCommerce add-on you are using and if this date is a product attribute or a customer option?
dhinesh replied on at Permalink Reply
dhinesh
I've added a attribute under shipping in the Order Attributes in ecommerce settings.
hutman replied on at Permalink Reply
hutman
If you only need to fix this in the receipt email you can change /packages/core_commerce/mail/receipt.php and add

if (strpos($val, ' 00:00:00') !== false) {
   $val = str_replace(' 00:00:00', '', $val);
}


into the loop of the shipping_attrs (around line 65 in the one I'm looking at) and that will remove the time portion of that value before it's printed.

Doesn't answer why it still shows, but at least it will fix the problem you're having.
dhinesh replied on at Permalink Reply
dhinesh
Thanks for your reply.
But i've done it in other way.
tsilbermann replied on at Permalink Reply
tsilbermann
Have the same problem - but use 5.7
Any idea how I can solve it there?

Torsten