tags:

views:

24

answers:

1

Hi

I am trying to use the jquery timepicker and have the following issues I want to show the start time which is in the time zone I am setting it to. I cannot use startTime = new Date() as that takes the system time and if that is different for each user from different location the time is going to be different. I am trying to allow users to create an event, so they pick a date and choose time, in the time field with the timepicker, it shows the time but I want to have the start time based on the current time in the time zone.

I found this time zone in jquery(in stackoverflow) but the problem is how I can use this for the startTime in the timepicker.

$(document).ready(function(){
  var timezone = "Europe/Berlin";
  $.getJSON("http://json-time.appspot.com/time.json?tz="+timezone+"&callback=?",
    function(data){
      if (data.hour < 12) {
        alert ("Good morning in "+timezone);
      } else {
        alert ("Good afternoon in "+timezone);
      }
    })
});

this is what I have from timepicker

$("#time2").timePicker({
 startTime: new Date(),
 show24Hours: false,
 separator: '.',
 step: 15});

so for the startTime, i need to pass the current time in the specified timezone.

any help please?

A: 

i imagine:

$(document).ready(function(){
var t;
var timezone = "Europe/Berlin";
$.getJSON("http://json-time.appspot.com/time.json?tz="+timezone+"&amp;callback=?",
function(data){
     t = data.time // you may have to console.log data to see what you have.
  }
})
$("#time2").timePicker({
startTime: t,
show24Hours: false,
separator: '.',
step: 15});
});
Orbit