Solved

How to update event after 24h

Posted on 2014-02-14
7
304 Views
Last Modified: 2014-04-01
Unix Time is saved in the database: 1399907792

I want after 24 hours from the time 1399907792 will update event, using php script
0
Comment
Question by:newbades
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 250 total points
ID: 39860998
24 hours after 1399907792 is 1399907792 + 24 * 60 * 60 = 1399994192

In php you would do $newtime = strtotime('+1 day', $dbtime);

HTH,
Dan
0
 

Author Comment

by:newbades
ID: 39861102
I want after 24h will update the new event and continue after 24h .....
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39861109
Post your code, because it does not make much sense what you're writing.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39861192
This article should tell you most everything you need to understand the fundamentals of how PHP works with date / time values.  Please read it over and post back if you still have any questions.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

In unrelated matters, please visit this URL, where Experts-Exchange is still waiting to hear your explanation for giving a marked-down grade.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28360134.html
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 39861213
As with most things about computers, the devil is in the details.  Have a look at this, then consider what's written below.

<?php // RAY_temp_newbades.php
error_reporting(E_ALL);
echo '<pre>';

// SEE http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28365589.html

// A UNIX TIMESTAMP
$uts = 1399907792;

// VISUALIZE THE ISO-8601 FORMAT DATE STRING
$iso = date('c', $uts);
echo PHP_EOL . "TIMESTAMP $uts => ISO DATE $iso";

// ADD 24 HOURS (MAYBE)
$new = date('c', strtotime($iso . ' + 1 DAY'));
echo PHP_EOL . "ADDING ONE DAY: $new";

Open in new window

PHP is a server-side scripting language.  Since it runs on the server, it cannot initiate any action; the action is initiated by a request from a client.  The italicized words are terms of art in modern information technology.  When software developers want to trigger a time-driven event on a server, they use an equivocation client, such as a scheduled task or CRON job.  More on the nature of client/server protocols is available in this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html

When you say you want something to happen 24 hours after some point in time, you need to be aware of the meaning of 24 hours.  If what you really want is for the event to happen at the same time one day later, that may or may not be 24 hours!  Daylight savings time can cause a day to be more or less than 24 hours.  You do not have to worry too much about DST because PHP is aware of it, depending on your timezone, and can adjust for it.  If you stick with the definition of 24 hours, your event schedule may change in the zones where daylight savings time is in play.

A value in a data base cannot trigger an event.  Instead, a client must make a request of the server, and the server must examine the data base to see if the event should be triggered.  When and how frequently you might examine the data base are questions of business logic.  What if the event were off by a few seconds or even a few minutes?  The timestamp in play here establishes 2014-05-12T10:16:32-05:00 which is 10:16:32 in prevailing Central Time on May 12th, 2014.  Would it matter if the event trigger fired at 10:16:00 or 10:17:00?  These questions are important because one of the likely event triggers, a CRON job, can only be scheduled to the minute, not the second.  There is also the risk that the server time is not exact with respect to some chosen standard, but that risk seems to grow smaller over time, as servers get smarter about synchronized clocks.

Some of these questions will be easier for you to answer after you have read the article.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question