i have date in pst format in database and i am passing it from backend via C# to javascript and then trying to convert it to client local time and here is the code i am using to convert it
onverttDate: function (element,date)
{
var Element = $(element);
var d1 = new Date(date);
var newDate = new Date(d1.getTime() + d1.getTimezoneOffset() * 60 * 1000);
var offset = d1.getTimezoneOffset() / 60;
var hours = d1.getHours();
newDate.setHours(hours offset);
Element.append('<div>' + newDate + '</div>');
}
and the date string i am getting from backend to javascript function is May 24,2014 09:59:59 and the converted date should be May 24,2014 22:59:59
i am not able to spot bug,i tried using moment.js also but its also not working. Please give me a solution for this as what i am doing wrong. Any, js fiddle example hardcoding date string as it is will also be appreciated Note:I am getting date string from ajax call from server