Comparing date with current date and showing different data for each

0

Hi there,

I've got a record label website where i'm using pods for releases and i'm trying to show different data based on the release date and how it compares to the current date.

For example: If the release date is 10/14/2011 and it's 10/15/2011, show "Out Now", otherwise show the release date.

The code i have so far kind of works, but i'm not a PHP developer, so i'm not sure why it's not working. It consistently shows "Out Now" regardless of the release date i set: (Below is the helper i've created for this)

<?php
if ( strtotime($this -> get_field ( 'release_date' )) < strtotime(date('m j, Y')) ) {
    echo '<span class="rstat cur">Out Now:</span> <a href="'; echo $this -> get_field ('beatport_link'); echo '" class="lnk btp">Get '; echo $this -> get_field ('name'); echo ' on Beatport</a>';
} else { 
    echo $this->pod_helper('format_date',$this->get_field('release_date'),'release_date'); 
} 

And here's how i'm calling it in the template: {@name, release_date}

Any help would be appreciated. Thanks!

asked Nov 17 '11 at 12:38

Stefan Weise

15

edited Nov 17 '11 at 12:39

add comment
enter at least 15 characters

2 Answers

1

Dates are kind of funny in PHP. Try this.

if ( strtotime($this->get_field('release_date')) < time() ) {

answered Nov 17 '11 at 1:12

chris.pilko

889

add comment
enter at least 15 characters
0

Thank you. That worked perfectly.

answered Nov 17 '11 at 3:45

Stefan Weise

15

add comment
enter at least 15 characters