Time difference between two times

To Calculate the difference between two dates you could try something like: long millis = date1.getTime() – date2.getTime(); int hours = (int) (millis / (1000 * 60 * 60)); int mins = (int) ((millis / (1000 * 60)) % 60); String diff = hours + “:” + mins; To update the Time Difference every second … Read more

Time difference in C++

I know this is an old question, but there’s an updated answer for C++0x. There is a new header called <chrono> which contains modern time utilities. Example use: #include <iostream> #include <thread> #include <chrono> int main() { typedef std::chrono::high_resolution_clock Clock; typedef std::chrono::milliseconds milliseconds; Clock::time_point t0 = Clock::now(); std::this_thread::sleep_for(milliseconds(50)); Clock::time_point t1 = Clock::now(); milliseconds ms = … Read more

PHP Timezone List

Take my array of time zones, which I made specially for select element. It is associated array where key is PHP time zone and value is human representation. This is it: $timezones = array( ‘Pacific/Midway’ => “(GMT-11:00) Midway Island”, ‘US/Samoa’ => “(GMT-11:00) Samoa”, ‘US/Hawaii’ => “(GMT-10:00) Hawaii”, ‘US/Alaska’ => “(GMT-09:00) Alaska”, ‘US/Pacific’ => “(GMT-08:00) Pacific … Read more