Use the invariant format
yyyy-MM-dd
. Since you're passing the value in the query-string, it will be parsed using the invariant culture:
Melvyn Harbour - MVC ModelBinder and Localization[
^]
If you want to include the time, you could use either
Date.prototype.toJSON()[
^] or
Date.prototype.toISOString()[
^].
Otherwise, if you don't have an existing date-formatting function, you can roll your own:
if (!Date.prototype.toISODateString) {
(function() {
function pad(number) {
if (number < 10) {
return '0' + number;
}
return number;
}
Date.prototype.toISODateString = function() {
return this.getUTCFullYear() +
'-' + pad(this.getUTCMonth() + 1) +
'-' + pad(this.getUTCDate());
};
}());
}
...
var response = $http.get(config.apiUrl + "GetMonthDates/" + writedate.toISODateString() + "?IsTodayDate=" + IsTodayDate);