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
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. :)

Link to comment
Share on other sites

 

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.