当前位置:网站首页>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边栏推荐
猜你喜欢
随机推荐
@Autowired注解 --required a single bean, but 2 were found出现的原因以及解决方法
2022年P气瓶充装操作证考试题库及模拟考试
关于rust的mongodb驱动count方法无法与near条件一同使用的问题
goland里的异常处理
JVM内存模型
TCP协议之《发送缓存控制tcp_notsent_lowat》
电流探头如何设置示波器参数
ZZULIOJ:1029: 三角形判定
2022年危险化学品经营单位主要负责人题库及模拟考试
ZZULIOJ:1020: 两整数排序
ZZULIOJ:1021: 三个整数的最大值
LeetCode 周赛笔记 —— 2022年8月 第一周
音乐现场的未来将被NFT门票主宰?
使用 DatePicker 日期控件,发生 Prop being mutated: “placement“ 报错问题
TCP协议之《对端MSS值估算》
redis基本数据类型
MindSpore官方RandomChoiceWithMask算子用例报错
Pytorch中的torch.index_select对应MindSpore哪个方法
Flutter 如何安装 pub.dev 上的 package
兴盛优选监控场景的时序数据库选型与落地实践









