Hi,
I am trying to implement the basic calendar for different people living in different timezones. They can add events for a particular date and time (which would be according to their timezone) in their calendar.I want to send notification email to them for that event that will occur.Now my server timezone will be different, so i am planning to convert the time(that the users will enter in their timezone) to standard timezone (i.e timezone of my server or GMT) while updating the events,date and time to my database.
For this, should i use cron job,scheduled ( every minute) to run a script which would check what events occur at that time and send a notification ?
I have hashed a sample code as below.
<?php
$con = mysql_connect("localhost","root","");[i] //Connection to the database[/i]
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cal", $con);
$date = date('jS F Y h:i A'); [i]// Taking GMT here, will be saving it in GMT too.[/i]
$result = mysql_querymysql_query("SELECT * FROM users WHERE eventtime= $date");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$to = $row["emailid"]; [i] //Sending Email[/i]
$subject = 'Event Notification';
$message = $row["event"];
$headers = 'From:
[email protected]' . "\r\n" .
'Reply-To:
[email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
?>