获取系统时间now,date

来源:互联网 发布:nginx error log 配置 编辑:程序博客网 时间:2024/05/22 12:54

直接在命令窗输入now,返回数字,这个数字一般无意义;输入date,返回具体日期

>> now



ans =


   7.3699e+05


>> date


ans =


23-Oct-2017

想要将时间精确到s,用datestr(now):





>> datestr(now)


ans =


23-Oct-2017 11:58:34


数组具体时间转为数组,代码如下:



>> time_1=datevec(datestr(now))


time_1 =


        2017          10          23          12           1          51


>> time_1(1),time_1(2)


ans =


        2017




ans =


    10

原创粉丝点击