标签:newlisp
这里要用到date函数的第三种形式,下面是获得当前日期
(set ‘today (date (date-value) 0 "%Y%m%d"))
第二个参数是偏移的分钟,0表示没有偏移,就是现在。 这个参数主要用来做时区转换
第三个参数定义日期格式,参考下表:
| format | description |
|---|---|
| %a | abbreviated weekday name according to the current locale |
| %A | full weekday name according to the current locale |
| %b | abbreviated month name according to the current locale |
| %B | full month name according to the current locale |
| %c | preferred date and time representation for the current locale |
| %d | day of the month as a decimal number (range 01–31) |
| %H | hour as a decimal number using a 24-hour clock (range 00–23) |
| %I | hour as a decimal number using a 12-hour clock (range 01–12) |
| %j | day of the year as a decimal number (range 001–366) |
| %m | month as a decimal number (range 01–12) |
| %M | minute as a decimal number |
| %p | either ‘am‘ or ‘pm‘ according to the given time value or the corresponding strings for the current locale |
| %S | second as a decimal number 0–61 (60 and 61 to account for occasional leap seconds) |
| %U | week number of the current year as a decimal number, starting with the first Sunday as the first day of the first week |
| %w | day of the week as a decimal, Sunday being 0 |
| %W | week number of the current year as a decimal number, starting with the first Monday as the first day of the first week |
| %x | preferred date representation for the current locale without the time |
| %X | preferred time representation for the current locale without the date |
| %y | year as a decimal number without a century (range 00–99) |
| %Y | year as a decimal number including the century |
| %z | time zone or name or abbreviation (same as %Z on Win32, different on Unix) |
| %Z | time zone or name or abbreviation (same as %z on Win32, different on Unix) |
| %% | a literal ‘%‘ character |
下面是使用了偏移参数计算昨天的日期:
(set ‘yesterday (date (date-value) (- (* 24 60)) "%Y%m%d"))
标签:newlisp
原文地址:http://blog.csdn.net/sheismylife/article/details/28091635