当前位置:网站首页>JS gets the year, month, day, time, etc. of the simple current time
JS gets the year, month, day, time, etc. of the simple current time
2022-08-10 04:29:00 【weixin_43923808】
var date = new Date();date .getYear(); //Get the current year (2 digits)date .getFullYear(); //Get the full year (4 digits)date .getMonth(); //Get the current month (0-11, 0 represents January)date .getDate(); //Get the current day (1-31)date .getDay(); //Get the current week X (0-6, 0 represents Sunday)date .getTime(); //Get the current time (the number of milliseconds since 1970.1.1)date .getHours(); //Get the current hour (0-23)date .getMinutes(); //Get the current minute (0-59)date .getSeconds(); //Get the current number of seconds (0-59)date .getMilliseconds(); //Get the current number of milliseconds (0-999)date .toLocaleDateString(); //Get the current datevar mytime=date .toLocaleTimeString(); //Get the current timedate .toLocaleString( ); //Get the date and time// get the current monthvar nowMonth = date.getMonth() + 1;// Get the current numbervar strDate = date.getDate();// add separator "-"var seperator = "-";// Process the month, add a "0" in front of the month from January to Septemberif (nowMonth >= 1 && nowMonth <= 9) {nowMonth = "0" + nowMonth;}// Process the month, add a "0" in front of the 1-9if (strDate >= 0 && strDate <= 9) {strDate = "0" + strDate;}// Finally concatenate the string to get a date in the format (yyyy-MM-dd)var nowDate = date.getFullYear() + seperator + nowMonth + seperator + strDate;// get the previous day's datevar time = (new Date).getTime() - 24 * 60 * 60 * 1000;var yesday = new Date(time); // get the previous day's date边栏推荐
猜你喜欢
随机推荐
TCP协议之《ACK报文限速》
若依系统前后台漏洞大全
3、ROS工作空间的创建
ZZULIOJ:1028: I love 闰年!
自定义训练,使用Generator dataset迭代数据报错
webrtc学习--websocket服务器(二) (web端播放h264)
智能锁控板的主要功能有哪些?如何使用?
矛盾的地方
2022/8/9
Pytorch中的torch.index_select对应MindSpore哪个方法
深入学习Synchronized各种使用方法
[crit] 23856#0: *101796511 stat()
LeetCode·301.删除无效的括号·BFS
用 PySpark ML 构建机器学习模型
TCP协议之《自动阻塞CORK控制》
域名DNS解析工具ping/nslookup/dig/host
进入Mysql数据库操作
2022华数杯思路分析
22牛客多校3 A.Ancestor(LCA + 枚举)
用.bat文件做Airtest脚本的多设备批量运行









