Solved

How do I find next day date by end time ?

Posted on 2014-09-29
8
302 Views
Last Modified: 2014-10-01
I have db with these details

Title (text)
Date Start Time (Timestamp)
Date End Time  (Timestamp)

Open in new window


I will get input as

"This is title"
09/29/2014
11:55 PM
03:35 AM

Open in new window


Now I need to calculate based on end time "03:35 AM".. the next day as "09/30/2014"?

How can I do this?

attached are my sample input screen.
0
Comment
Question by:Loganathan Natarajan
  • 5
  • 3
8 Comments
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 500 total points
ID: 40349913
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40349919
Now I need to calculate based on end time "03:35 AM".. the next day as "09/30/2014"?
How do you figure out that the next day is 09/30/2014?  Is this value always the current date + 1 day?  Give us a little more to go on, and I'll be glad to show you the calculations (or just read the article and you'll find many examples of date/time arithmetic).
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 40350254
Thanks Ray, let me go through your article first.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40350338
OK.  Once we know the rules for interpreting the times, it should be pretty easy to get the code together.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 40351497
I read the tutorial , it is useful and more details to work further. Thanks Ray.

but in my case different, just check the attachment screen. the input comes always one DATE and FROM, TO time ...

So, what is the best way to validate in my case?
doubt.png
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40352087
I'll try to show you what I think might work.  Install this script and run it, or test on my server here.
http://iconoun.com/demo/temp_loganathan.php
<?php // demo/temp_loganathan.php
error_reporting(E_ALL);
if (!empty($_GET))
{
    // INTERPRET THE DATES INTO TIMESTAMPS AND ISO-8601 DATETIME VALUES
    $alpha = date('c', strtotime($_GET['d'] . ' ' . $_GET['a']));
    $omega = date('c', strtotime($_GET['d'] . ' ' . $_GET['z']));

    // IF THE END DATE/TIME IS EARLIER THAN THE START, ADD A DAY
    if ($omega < $alpha) $omega = date('c', strtotime($omega . ' + 1 DAY'));

    // SHOW THE UNDERSTANDING OF THE DATES
    echo "Alpha: $alpha, Omega: $omega";
}

// CREATE THE FORM FOR INPUTS
$form = <<<EOF
<form>
Date:  <input name="d" /><br>
Start: <input name="a" /><br>
End:   <input name="z" /><br>
<input type="submit" value="Go!" />
</form>
EOF;
echo $form;

Open in new window

0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 40353936
Thanks ray. It is very helpful and fixed it.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40354228
Great!  Thanks for the points, ~Ray
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
File submission to SQL Server 1 38
can windows 10 wamp send mail()? 3 32
MySQL  on Tomcat 8 27
How to write an English digest paper 6 23
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 Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 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

22 Experts available now in Live!

Get 1:1 Help Now