Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to update event after 24h

Posted on 2014-02-14
7
Medium Priority
?
310 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 35

Accepted Solution

by:
Dan Craciun earned 1000 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 111

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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

885 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