datetime 取分钟_datetime-Javascript,时间和日期:获取给定毫秒值的当前分钟,小时,天,周,月,年...
變量名稱應具有描述性:
var date = new Date;
date.setTime(result_from_Date_getTime);
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hour = date.getHours();
var year = date.getFullYear();
var month = date.getMonth(); // beware: January = 0; February = 1, etc.
var day = date.getDate();
var dayOfWeek = date.getDay(); // Sunday = 0, Monday = 1, etc.
var milliSeconds = date.getMilliseconds();
給定月份的日期不變。 在a年,二月有29天。 受[http://www.javascriptkata.com/2007/05/24/how-to-know-if-its-a-leap-year/]的啟發(感謝Peter Bailey!)
接續先前的代碼:
var days_in_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// for leap years, February has 29 days. Check whether
// February, the 29th exists for the given year
if( (new Date(year, 1, 29)).getDate() == 29 ) days_in_month[1] = 29;
沒有簡單的方法來獲取一年中的一周。 有關該問題的答案,請參閱javascript中是否可以使用年份和ISO周號創建日期對象?
總結
以上是生活随笔為你收集整理的datetime 取分钟_datetime-Javascript,时间和日期:获取给定毫秒值的当前分钟,小时,天,周,月,年...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python分形几何_使用 Python
- 下一篇: elementui树形复选框_Eleme