简体   繁体   中英

Convert Any Date Inserted To ISO Format Without The Timestamp In JavaScript

I want to know how can convert any date that entered to text box using JQuery Datepicker to the ISO date format without the Timestamp. At the below you can find the code sample that I have used.

$("#to_date").datepicker({  maxDate: new Date(),dateFormat: 'yy-mm-dd'});
$("#from_date").datepicker({  maxDate: new Date(),dateFormat: 'yy-mm-dd'});

But when I pass these dates to a JSON web service it shows is invalid date. So what should I do?

Thanks & regards, Chiranthaka

From original documentation: Display the date in ISO format. Produces "2007-01-26".

$.datepicker.formatDate( "yy-mm-dd", new Date( 2007, 1 - 1, 26 ) );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM