# Calculating the difference between two dates in different timezones in hours and minutes [closed]

I need to calculate the difference between two dates in hours and in minutes which is what the code below does. The only issue I have is that the dates and the location (timezone) has to be input by the user. How do I achieve that? Can be a different language from PHP as I only need a flowchart and the pseudocode.

?php

$departure = new DateTime('8pm March 27, 2016 America/New_York');$arrival = new DateTime('7:20am March 28, 2016 Europe/London');

$flighttime =$departure->diff($arrival); echo "$flighttime-> h hours $flight_time->i minutes"; Output: 7 hours 20 minutes • What's the problem exactly? That the '8pm March 27, 2016 America/New_York' string comes from user input? Are you asking how to validate it? – Karolis Juodelė Nov 22 '16 at 14:24 •$departure = new DateTime('8pm March 27, 2016 America/New_York'); Inside of the bracket, I need that to be the user input, so the user inputs that information. – James Nov 22 '16 at 14:44
• So you're asking how to take a string from a some textarea in some html and run your code on it? – Karolis Juodelė Nov 22 '16 at 14:59
• Yes, I want the user to input the date and the location from which the timezone is taken and then run the code on it to calculate the difference between the two inputted dates. – James Nov 22 '16 at 15:05
• You're asking for an algorithm but this is something for which you should use your programming environment's built-in date and time handling routines, rather than trying to roll your own code. This is the sort of thing where reinventing the wheel just causes mistakes from obscure cases. – David Richerby Nov 22 '16 at 16:25