?
Solved

How to update event after 24h

Posted on 2014-02-14
7
Medium Priority
?
307 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 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

718 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