• I’m using the templating for a custom display. I’ve instantiated PDb_Template() and using get_value() to retrieve the value of a date field.

    $record = new PDb_Template( $this );
    $date_field = $record->get_value(‘start_date’);

    I’m putting the date field through the date() function and treating the second parameter as a string, converting it to time() via strtotime(). However, I’m getting a null value and the date display only shows today’s date. I’m thinking that maybe I don’t need the strtotime() function in date, since maybe the data is stored as time() format but I haven’t been able to find any documentation that explicitly states this. If I want to use date(), could I just input the value of $date_field or do I still need to use with strtotime()?

    $date_display = date( ‘YYYY-MM-DD’, strtotime($date_field) );

Viewing 1 replies (of 1 total)
  • Plugin Author Roland Barker

    (@xnau)

    Using the “get_value” method on a date field will give you the Unix timestamp, so you don’t need strtotime.

    Also, the format string you’re using isn’t the right kind of format string, you need to use a php Date format string. Take a look at the linked article for the details.

Viewing 1 replies (of 1 total)

The topic ‘Date Display Empty With $record->get_value()’ is closed to new replies.