Skip to main content

Posts

Showing posts with the label time

How to convert Milliseconds to "X mins, x seconds” in Java?

I want to record the time using System.currentTimeMillis() when a user begins something in my program. When he finishes, I will subtract the current System.currentTimeMillis() from the start variable, and I want to show them the time elapsed using a human readable format such as "XX hours, XX mins, XX seconds" or even "XX mins, XX seconds" because its not likely to take someone an hour. What's the best way to do this?

jQuery FullCalendar timezone syncronization

I am using the jQuery Fullcalendar plugin (http://arshaw.com/fullcalendar). I am only using it for "full day" events. When the user creates an event, I store it in my database via php as a date (2012-01-12). When sending the list of events to FullCalendar via ajax I convert the date to UNIX time. The problem I am foreseeing, is the case where say the server is in the US with a US timezone, and the client is in Europe. The server sends an event for 2012-01-12 00:00:00 (US Time), which gets converted to a unix time. Then the client may see an event that is at 2012-01-12 08:00:00 (8 hours later). How can I make sure that if an event is at midnight, then it's at midnight EVERYWHERE - no need adjust any timezone. If a user creates a full day event on January 12th, I need every user around the world to see it on that same date as well.