web前端:JS基础语法---Date对象---格式化日期

    作者:jane_panyiyun更新于: 2020-03-16 20:56:16

    Web开发

      data返回代表特定日期的序列号。如果在输入函数前,单元格格式为"常规",则结果将设为日期格式。

      在其它程序设计中(如:vfp,vb,C等语言),date函数作用为取得当前系统日期,且不需要参数。

      格式化后的指定格式的日期和时间,封装一个函数

      functiongetDate(){

      vardt=newDate();

      varyear=dt.getFullYear();

      varmonth=dt.getMonth();

      vardate=dt.getDate();

      varhour=dt.getHours();

      varminute=dt.getMinutes();

      varsecond=dt.getSeconds();

      month=month<10?"0"+month:month;

      date=date<10?"0"+date:date;

      hour=hour<10?"0"+hour:hour;

      minute=minute<10?"0"+hour:hour;

      second=second<10?"0"+second:second;

      returnyear+"年"+month+"月"+date+"日"+hour+":"+minute+":"+second;

      }

      console.log(getDate(newDate()));

      字符串或串(String)是由数字、字母、下划线组成的一串字符。一般记为s="a1a2···an"(n>=0)。它是编程语言中表示文本的数据类型。在程序设计中,字符串(string)为符号或数值的一个连续序列,如符号串(一串字符)或二进制数字串(一串二进制数字)。

课课家教育

未登录