const date = new Date(); const year = date.getFullYear().toString(); const month = ('0' + (date.getMonth() + 1)).slice(-2); const day = ('0' + date.getDate()).slice(-2); return `${year}-${month}-${day}`;
getToday() {
      let d = new Date();
      let year = new Date().getFullYear();
      let month = new Date().getMonth() + 1;
      let date = new Date().getDate();
      month = month < 10 ? `0${month}` : month;
      date = date < 10 ? `0${date}` : date;
      return `${year}-${month}-${date}`
项目源码:
$(#createTime).text((new Date(jumpParams.createDate.time).Format(yyyy-MM-dd hh:mm:ss)));
$(#updateTime).text((new Date(jumpParams.updateDate.time).Format(yyyy-MM-dd hh:mm:ss)));
xxx.Format(yyyy-MM-dd hh
var isoDate = require ( 'iso-date' ) ;
isoDate ( '2011-11-11 11:11:11' ) ;
// "2011-11-11"
isoDate ( 1444047247887 ) ;
// "2015-10-05"
isoDate ( ) ;
// todays date, e.g: "2015-10-05"
isoDate ( new Date ( ) ) ;
// todays date, e.g: "2015-10-05"
isoDate(date)
返回: String ,日期字符串,格式为“ YYYY-M
                                    如果在asp我们可以用year(date())这样的格式在sql语句,不知道这样的效率怎么样不过是个方法 代码如下:select substring(convert(char,registdate,120),1,10) as registdate from tbuser
                        您可能感兴趣的文章:将WMIDateTime类型转换成VBS时间的函数代码LINQ字符串向datetime 转换时失败的处理方法时间字符串转换成日期对象datetime的方法Sqldatetime转换成字符串的方法(CONVERT)Python实现对Timestam
var myDate = new Date();  
myDate.getYear(); //获取当前年份(2位)  
myDate.getFullYear(); //获取完整的年份(4位,1970-????)  
myDate.getMonth(); //获取当前月份(0-11,0代表1月) 所以获取当前月份是 myDate.getMonth()+1;   
myDate.getDate(); //获取当前日(1-31)  
myDate.getDay(); //获取当前星期X(0-6,
                                    js可以通过Date对象获取当前日期和时间,使用Date()获取系统当前时间,在使用getFullYear()、getMonth()、getDate() 、getHours()等方法获取特定格式的时间,在使用innerHTM方法显示。
首先我们来了解一下js获取当前时间所需的一些方法:
获取当前时间:
var d = new Date();//获取系统当前时间
获取特定格式的时间:
1、获取当前年份
getYear()方法:可以获取年份(2位或4位),其返回值是表示当前Date 对象的年份字段
说明:当年
                                    默认情况下,它使用我们浏览器的时区并将日期显示为全文字符串,例如包含当前日期、时间和时间的“Fri Jun 17 2022 10:54:59 GMT+0100 (British Summer Time)”区。假设我们不想在我们的日期值之间使用破折号 (-),我们所要做的就是用我们喜欢的任何东西替换破折号。我们刚刚看到了如何使用日期方法获取当前日期。现在让我们看看如何使用该方法,除了时间格式之外,toJSON()它还以格式返回我们的日期, .yyyy-mm-ddhh:mm:ss.ms。
                                    使用dayjs获取当前时间1、在项目安装dasjs: npm install --save dasjs。2、vue局部引用:  import dayjs from 'dayjs';