Home >Web Front-end >JS Tutorial >Analysis of the method of obtaining year, month, day, hour, minute and second using JS

Analysis of the method of obtaining year, month, day, hour, minute and second using JS

高洛峰
高洛峰Original
2016-12-03 16:50:181546browse

The example of this article analyzes the JS method of obtaining the year, month, day, hour, minute and second. Sharing it with everyone for your reference, the details are as follows:

var d = new Date();
var time = d.getFullYear() + "-" +(d.getMonth()+1) + "-" + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();

It has to be so complicated, there is no way.

I thought jQuery would be able to streamline functions, but found that it wasn’t.

You can only use this primitive writing method to get the information of year, month, day, hour, minute and second.

tips:

JS cannot have spaces when passing parameters, otherwise the data will not be obtained.

url="send.php?action=record_info&order_id=" + $("#order_id").val() + "&remark = "+$('#remark').val();

There are spaces before and after the equal sign after the remark parameter above, resulting in no data being obtained.

Correct writing:

url="send.php?action=record_info&order_id=" + $("#order_id").val() + "&remark="+$('#remark').val();


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn