Comparing date with current date and showing different data for each
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!
edited Nov 17 '11 at 12:39
2 Answers
Dates are kind of funny in PHP. Try this.
if ( strtotime($this->get_field('release_date')) < time() ) {
Thank you. That worked perfectly.


