ISO string output is the right way.
You will probably find it helpful to use JavaScript Date toISOString . Since not every browser supports it, you want to provide it for browsers that do not:
if ( !Date.prototype.toISOString ) { ( function() { function pad(number) { var r = String(number); if ( r.length === 1 ) { r = '0' + r; } return r; } Date.prototype.toISOString = function() { return this.getUTCFullYear() + '-' + pad( this.getUTCMonth() + 1 ) + '-' + pad( this.getUTCDate() ) + 'T' + pad( this.getUTCHours() ) + ':' + pad( this.getUTCMinutes() ) + ':' + pad( this.getUTCSeconds() ) + '.' + String( (this.getUTCMilliseconds()/1000).toFixed(3) ).slice( 2, 5 ) + 'Z'; }; }() ); }
This is taken directly from MDN toISOString . I use it, and I hope most others do too.
Note that Z stands for Zulu time (GMT). You can simply use midnight ( T00:00:00.000Z ) so that there is no time. Personally, I tend not to care about the millisecond part for what I do, and omit it (the temporal resolution is reduced to the second).
As long as you standardize the ISO format, you can easily write simple parsers for both the server and the client, if necessary.
Regarding the DateTime binding in MVC, you should parse the input value using the methods described in this answer . Key / date syntax analysis is a sequence, and as long as you can depend on the ISO format (either with T or with a space), you can easily control it.
source share