简体   繁体   English

摆脱返回字符串中的时间戳

[英]getting rid of timestamp in returned string

I want to get rid of the timestamp in this returned string.我想去掉这个返回字符串中的时间戳。 I am currently getting: "You have selected: Fri Sep 08 1978 00:00:00 GMT-0400 (EDT)"我目前收到:“您已选择:1978 年 9 月 8 日星期五 00:00:00 GMT-0400 (EDT)”

The code is:代码是:

var chosenDates = $.datepicker.parseDate('yy-mm-dd', dateText);
$('.info').html('You have selected:' + '<br />' + chosenDates.toString());

You can specify the format in the toString method.您可以在toString方法中指定格式。 For example:例如:

var chosenDates = $.datepicker.parseDate('yy-mm-dd', dateText); 
$('.info').html('You have selected:' + '<br />' + chosenDates.toString('dd-MM-yyyy')); 

Edit: Or if you want to use the same format as in the date-picker: yy-mm-dd编辑:或者如果您想使用与日期选择器中相同的格式: yy-mm-dd

Edit: You can also try with the formatDate function:编辑:您也可以尝试使用格式日期formatDate

var chosenDates = $.datepicker.parseDate('yy-mm-dd', dateText); 
var backToString = $.datepicker.formatDate('yy-mm-dd', chosenDates);
$('.info').html('You have selected:' + '<br />' + backToString); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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