Date Format

edited April 2016 in Feature Requests
I have a date picker setup in Fuel with date and time. When the date is updated it updates on the front-end. Right now it's displaying as:

17:00:00 - 20:00:00

Is there a way to update the date format? I've tried several ways, followed several links, but can't seem to figure it out.

Here is my script inside the template page:

<?php echo fuel_var('event_date'); ?> <br> <?php echo fuel_var('start_time', ''); ?> - <?php echo fuel_var('end_time', ''); ?>


  • edited 2:14AM
    If you using the fuel_var function it will output the variable along with code to make it inline editable as well as apply a default parameter. You can always access the variable like so:
    $formatted_date = date('m/d/Y', strtotime($event_date)); // change the format to whatever you want echo $formatted_date;
  • edited 2:14AM
    Awesome. That worked for the date.

    Do I use the same var function for time? In the database I have them as 'start_time' and 'end_time'.
  • edited 2:14AM
    I'm not sure I understand what you mean by var function? Do you mean fuel_var or the PHP date function?
  • edited April 2016
    My programming rhetoric isn't so great.

    The time part of it is an admin function I added to Fuel, and it's suppose to display:
    5pm - 8pm, rather then 24hour time:

    This is what I'm using to display the time on the front end:

    <?php echo fuel_var('start_time', ''); ?> - <?php echo fuel_var('end_time', ''); ?>
  • edited 2:14AM
    Because fuel_var will by default also add additional code for inline editing, I'd use the raw variable and manipulate it as above.
    echo date('h:ma', strtotime($start_time)) .' - '.date('h:ma', strtotime($end_time));
    Are you familiar with the different formatters for the date function that is listed above?
  • edited 2:14AM
    That worked great. Referencing the date function link, I displayed it like this:

    echo date('ga', strtotime($start_time)) .' - '.date('ga', strtotime($end_time));

    Thank you.
Sign In or Register to comment.