Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does angularjs bootstrap datepicker pick one day before?

I'm using angularjs bootstrap datepicker directive and when I set a date from model it picks a day before the selected date.

<button type="button" class="btn btn-sm btn-default" ng-click="dt = '2014-09-24'">2014-09-24</button>

Here is a plunk with the issue.

Is there any solution?

like image 220
Charger513 Avatar asked Dec 19 '22 11:12

Charger513


1 Answers

For anyone needing a solution in the .NET Web Api world, this line worked well for me:

GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local;

It was due to the JsonFormatter spitting out the time in the wrong time zone.

like image 55
John Lee Avatar answered Feb 13 '23 16:02

John Lee