如何在javascript中修剪日期+时间字符串的时间部分



我在javascript中接收json数据,作为包含某些事件的日期和时间的字符串列表。

我构造了一个数组,并将它们存储在数组中。

存储格式为dd/mm/yyyy hh:mm:ss。我想知道是否有一种方法可以从数组中提取这个字符串的日期部分。

// run a loop to parse thru all elements in the array. //
t = (Service_date_from[count]); // 't' is what contains the date time once extracted from the array with a counter variable called `count`

在javascript中有任何类型的日期格式化功能吗?

如果总是这样格式化,您可以简单地使用substr

var idx = t.indexOf(" ");
var timeStr = t.substr(idx + 1);

最新更新