您的位置:首页 > 其它

获取当天时间信息

2015-01-24 22:10 218 查看
(now)函数可以很方便的返回当前时间信息,比如年,月等,返回结果存放在list中,使用十分方便。举例如下:
> (now)
(2015 1 24 14 7 42 393413 24 6 480 0)

注意,这里获得是GMT+0时区,如果想要获得中国时区,需要在第一个参数中指定以分钟为单位的整数。中国是GMT+8,所以应该如下调用:
> (now (* 8 60))
(2015 1 24 22 9 9 707743 24 6 480 0)

下面这段来自newlisp manual,这个list的信息非常丰富,可以提取周几的信息。

formatdescription
yearGregorian calendar
month(1–12)
day(1–31)
hour(0–23) UTC
minute(0–59)
second(0–59)
microsecond(0–999999) OS-specific, millisecond resolution
day of current yearJan 1st is 1
day of current week(1–7) starting Monday
time zone offset in minuteswest of GMT
daylight savings time type(0–6) on Linux/Unixor bias in minutes on Win32
下面是返回GMT+8时区今天是星期二

> ((now (* 8 60)) 8)
2
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  newlisp
相关文章推荐