1

I don't know what to put in search bar since I have no idea what to call it so, my bad if I have duplicate topic.

I seriously don't know how to put this but, I'll give an example.

Let's say, there's an event on January 20, 2013 09:30:00. Today's date is January 11, 2013 15:25:00.

I want to echo something a day before the event on January 20, 2013. (24 Hours before the Event)

It's like on January 19, 2013 I will receive or echo something that should remind me that tomorrow is the event takes place.

Well I have this code that I'm working on but still, it feels so wrong.

$start_ts = strtotime("2013-01-10 20:15:00"); //
$now_ts = strtotime("now");
$result_ts = $start_ts - $now_ts;
$reminder = ( 60 * 24 ) * 60; // 24 hours period

if ($result_ts <= $reminder) {
    echo "Today's a date before the event day";
} else {
    echo "Event is already finished";
}

The output is:

enter image description here

It should echo "Event is already finished"

To be honest, I'm losing my track here. Hope you guys help me, would be glad though.

Wesley Brian Lachenal
  • 4,381
  • 9
  • 48
  • 81

1 Answers1

1

Here is the magic:

if ($result_ts <= $reminder && $result_ts > 0) { //blah blah }
Valeh Hajiyev
  • 3,216
  • 4
  • 19
  • 28
  • Wouldn't have thought that it would worked though. Thanks! But, I don't understand it. If the Date today is January 11, 2013, then changed the $start_ts into January 12, 2013, it echoed Today's the day before the event day, but if I changed it to January 13, 14, 15 or so why did it still worked? Since the "$result_ts > 0" and it should give positive values right? the Date is greater than 11. – Wesley Brian Lachenal Jan 11 '13 at 04:04
  • Ohh! I already get it. I experimented a bit. Thanks a lot though. a very very very big help from you. :) – Wesley Brian Lachenal Jan 11 '13 at 04:11