Keyword

Date extra field format

  • Carlos
  • Carlos's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 2 months ago #115682 by Carlos
Date extra field format was created by Carlos
Hi.

I'm having trouble trying to change the date format of a k2 date extra field in a K2 content module?

I use this code for displaying the field:
<!-- Call to prepare extra field IDs -->
          <?php 
     //convertArray to use ids as key
          $extrafields_value = array();
          foreach($item->extra_fields as $itemid)
          {    
          $extrafields_value[$itemid->id] = $itemid->value;
          }   
          ?>
<!-- Call to prepare extra field labels -->
           <?php 
     //convertArray to use labels as key
          $extrafields_label = array();
          foreach($item->extra_fields as $itemlabel)
          {    
          $extrafields_label[$itemlabel->id] = $itemlabel->name;
          }
                  

          ?>
          
          
          
<?php echo $extrafields_value[11]; ?>

That displays the date like "VRIJDAG, 16 AUGUSTUS 2013" (in dutch).

What I need to have is Month/Day/Year

I tried this code:
<?php echo JHTML::_('date', $extrafields_value[11] , JText::_('m/d/y')); ?>

But it breaks the site and gives me this error:

0 - DateTime::__construct() [datetime.--construct]: Failed to parse time string (vrijdag, 16 augustus 2013) at position 0 (v): The timezone could not be found in the database

I tried a few other things but I either get that error or the date just doesn't get displayed.

Hope someone can help me.

Thanks!

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum