Page 1 of 1

Date and time

Posted: Tue Sep 25, 2007 4:04 am
by shivam0101
Hello,

I have to send emails exactly 24 hours before an event occurs. The system then waits for 5 minutes then again checks is there any new event within next 24 hours.

I am stroing the event date in

Code: Select all

date('Y:m:d H:i:s');
format.

1. How to check the event if it is inbetween? i.e if the event is for 10:12 PM and the system check every 5 minutes

the event will never be equal as it will check once at 10:10 and again at 10:15

2. Should i have to convert

Code: Select all

date('Y:m:d H:i:s')
to

Code: Select all

time()
? to comparing?

If there is any better way of doing it, please let me know.

Thanks

Posted: Tue Sep 25, 2007 4:16 am
by N1gel
Just off the top off my head

If you have both dates saved to php variables could just test them as dates

Code: Select all

if($event > $PreviousDate and $event < $CurrentDate)
{

}

Posted: Tue Sep 25, 2007 4:41 am
by aceconcepts
First of all you are storing the time and date as 1 value.

Try seperating your date and time values.

Regarding your time checker, as you already know the times of the events, you could base your "checking" script relative to the event's time. So instead of checking every 5 minutes set a pre-determined time that the emails should be sent.

Using a pre-determined time will also save server load.

I hope this is clear?

Posted: Tue Sep 25, 2007 5:28 am
by superdezign
Or, just check if the particular date has passed and, if it has, mail the notification and remove it from the queue. Keep it simple.

Posted: Tue Sep 25, 2007 5:31 am
by aceconcepts
But he wants to check for events 24hrs before they happen!

Posted: Tue Sep 25, 2007 5:44 am
by superdezign
aceconcepts wrote:But he wants to check for events 24hrs before they happen!
Yes, which would be the date to check against.

Posted: Tue Sep 25, 2007 9:53 am
by pickle
Do what ~ N1gel said.