Solved

How to update event after 24h

Posted on 2014-02-14
7
288 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
  • 2
  • 2
7 Comments
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 250 total points
Comment Utility
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
Comment Utility
I want after 24h will update the new event and continue after 24h .....
0
 
LVL 34

Expert Comment

by:Dan Craciun
Comment Utility
Post your code, because it does not make much sense what you're writing.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to dynamically set the form action using jQuery.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now