Chinaunix首页 | 论坛 | 博客
  • 博客访问: 302858
  • 博文数量: 82
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 490
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-13 10:58
文章分类

全部博文(82)

文章存档

2018年(2)

2017年(9)

2016年(71)

我的朋友

分类: 嵌入式

2016-11-25 12:45:00

一、os.date
local getTime = os.date(“%c”);

其中的%c可以是以下的一种:(注意大小写)

%a abbreviated weekday name (e.g., Wed)
%A full weekday name (e.g., Wednesday)
%b abbreviated month name (e.g., Sep)
%B full month name (e.g., September)
%c date and time (e.g., 09/16/98 23:48:10)
%d day of the month (16) [01-31]
%H hour, using a 24-hour clock (23) [00-23]
%I hour, using a 12-hour clock (11) [01-12]
%M minute (48) [00-59]
%m month (09) [01-12]
%p either “am” or “pm” (pm)
%S second (10) [00-61]
%w weekday (3) [0-6 = Sunday-Saturday]
%x date (e.g., 09/16/98)
%X time (e.g., 23:48:10)
%Y full year (1998)
%y two-digit year (98) [00-99]
%% the character ‘%’

二、常用获取时间格式
时间戳:os.time()    -- 1480048590
年月日:os.date(“%Y-%m-%d %H:%M:%S”)     -- 2016-11-25 12:35:47
阅读(2263) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~