1
 $(function() {
    $('#datepicker').datepick({ 
        multiSelect: 999, 
        monthsToShow: 3,
        minDate: new Date(), 
                maxDate: '+1y', 
        showTrigger: '#calImg',
        dateFormat: 'yy-mm-dd',        
        onSelect: function(value) { 
            alert(value);
                } 
    });
 });

this code block returns a string like that "Wed Jan 11 2012 12:00:00 GMT+0100". How can I convert that string like that "2012-01-11 12:00:00"?

mauris
  • 42,982
  • 15
  • 99
  • 131
marcom
  • 13
  • 1
  • 4

1 Answers1

5

You can use this to covert to local time and get rid of GMT

function getLocalTimeFromGMT(sTime){ 
  var dte = new Date(sTime); 
  dte.setTime(dte.getTime() - dte.getTimezoneOffset()*60*1000);       
  document.write(dte.toLocaleString()); }

cf http://teck.in/indian-standard-time-and-gmt-from.html#ixzz1hNGiQAhg

First Zero
  • 21,586
  • 6
  • 46
  • 45
  • I have to correct you by saying that when you go and toLocaleString() it converts the time back to the local time. You could just stop on the line before. Get it? – luiscabus Oct 29 '13 at 09:09