当前位置:网站首页>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边栏推荐
猜你喜欢
随机推荐
域名DNS解析工具ping/nslookup/dig/host
TCP协议之《Out-Of-Window报文限速》
TCP协议之《对端MSS值估算》
TCP协议之《MTU探测功能》
Unity实现UI的边缘检测和拖拽拉伸功能
【mindspore产品】【8卡分布式训练】davinci_model : load task fail, return ret
ZZULIOJ:1019: 公园门票
sql注入之宽字节注入,limit,order by
多元函数的3D可视化,终于被我总结出来了,数学真是太美了
UDP协议之《套接口阻塞选项UDP_CORK》
webrtc学习--websocket服务器
TCP协议之《数据与控制流程交叉时的延迟处理》
X书6.89版本shield-unidbg调用方式
【无标题】
释放高通量算力价值潜能 JASMINER持续领跑 Web3 市场
22牛客多校3 A.Ancestor(LCA + 枚举)
GBase 8s打开工具就报错“配置文件有误” !!!为什么
虚假新闻检测论文阅读(八):Assessing Arabic Weblog Credibility via Deep Co-learning
ZZULIOJ:1030: 判断直角三角形
TCP协议之《ACK报文限速》









