Jump to content

comparing user set date to local date


hunterchristy

Recommended Posts

so i'm working on a band website.

 

they have a discography page. for each album, they input a release date.

they have a new record coming out in a few months. it got me thinking, that if i could compare the local date to the user input date, before it comes out, i could print "coming soon," until it comes out, and then "out now!" for a period of a few weeks after the release.

 

i have a very basic understanding of how this would work, but i can't figure out how to call the local date. does anyone know?

Link to comment
https://forums.phpfreaks.com/topic/171712-comparing-user-set-date-to-local-date/
Share on other sites

ahhh. you're correct, i should have been more specific. technically, i want the SITE's date.

 

this is for a drupal site and after a bunch of searching and searching and searching, i found they specify this: 'tz_handling' => 'site' for the site's date.

 

i'm still working on it. once i THINK i'm onto something, i'll post my noob code for ya'll to have a chuckle at. :)

 

so here's what i've got right now. and it's not working.

 

i'm doing this in views in drupal, and i have "field_releasedate_value_1" spitting out a unix string. and i can, for instance, say "print $release" and it will print said string. AND i can print $today and get a string. BUT trying to print $unix isnt working, nor is trying to compare the two.

 

<?php
$today = date(U);
$release = $fields['field_releasedate_value_1']->content;
$unix = date("U", strtotime($release));
$soon = 'COMING SOON!';
$space = ' ';
if ($unix > $today) {
print $space;
    print $soon;
}	else {
print $space;
}
?>

 

can someone kick me in the right direction?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.