Solved

How to update event after 24h

Posted on 2014-02-14
7
297 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
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 34

Expert Comment

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

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 109

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checkout Page Input Field not aligned 1 26
How do uses indexes to maximize MySQL Searches 14 55
MVC - procedural PHP 10 35
Showing multiple maps using PHP and Google Maps 8 19
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

861 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