30 November, 2012
0 Comments
1 category
If you want to convert a date object to a string in JavaScript and you use jQuery, then you can use the function $.datepicker.formatDate.
The following QUnit test will succeed:
/// <reference path="Scripts/qunit.js"/> /// <reference path="Scripts/jquery-1.8.3.js"/> /// <reference path="Scripts/jquery-ui-1.9.2.js"/> "use strict"; test('JsTest', function () { var input = new Date(2012, 10, 28); // Note: months start at zero! var expected = '2012-11-28'; var actual = $.datepicker.formatDate('yy-mm-dd', input); ok(expected == actual, 'Dates are not equal. Expected:' + expected + ' _ Actual:' + actual); });
Tags: Javascript
Category: Uncategorized