Lua獲取系統(tǒng)時(shí)間和時(shí)間格式化方法及格式化參數(shù)
一、系統(tǒng)當(dāng)前時(shí)間對應(yīng)的時(shí)間戳
local ntime = os.time
print(ntime)
二、格式化時(shí)間顯示,參考下表
常用于設(shè)置header等
ngx.header["Last-Modified:"] = os.date("%a, %d %b %Y %X GMT")
ngx.header["Content-Type"] = "text/html; charset=utf-8"
ngx.header["Cache-Control"] = "public"
ngx.header["Expires"] = os.date("%a, %d %b %Y %X GMT", os.time() + cdnCacheTime)
%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 '%' |
相關(guān)文章
Lua編程示例(三):稀疏表、雙端隊(duì)列、格式化輸出、表和循環(huán)表的格式化輸出
這篇文章主要介紹了Lua編程示例(三):稀疏表、雙端隊(duì)列、格式化輸出、表和循環(huán)表的格式化輸出,本文直接給出實(shí)例代碼,代碼中包含詳細(xì)注釋,需要的朋友可以參考下2015-07-07舉例講解Lua中的Table數(shù)據(jù)結(jié)構(gòu)
這篇文章主要介紹了舉例講解Lua中的Table數(shù)據(jù)結(jié)構(gòu),說明都融入到了注釋中,需要的朋友可以參考下2015-07-07Lua loadstring函數(shù)用法實(shí)例
這篇文章主要介紹了Lua loadstring函數(shù)用法實(shí)例,loadstring最典型的用處是去執(zhí)行外部代碼,也就是位于程序之外的代碼,需要的朋友可以參考下2015-04-04