DateTime
DateTime ๊ฐ์ฒด์์.
์์ฑ
Year
Year์ ๋ํ๋ด์.
-- ์ํ --
local NewDateTime = DateTime.new(2022, 06, 30, 10, 30, 05)
print(NewDateTime.Year)
Month
Month๋ฅผ ๋ํ๋ด์.
-- ์ํ --
local NewDateTime = DateTime.new(2022, 06, 30, 10, 30, 05)
print(NewDateTime.Month)
Day
Day๋ฅผ ๋ํ๋ด์.
-- ์ํ --
local NewDateTime = DateTime.new(2022, 06, 30, 10, 30, 05)
print(NewDateTime.Day)
Hour
Hour๋ฅผ ๋ํ๋ด์.
-- ์ํ --
local NewDateTime = DateTime.new(2022, 06, 30, 10, 30, 05)
print(NewDateTime.Hour)
Minute
Year์ ๋ํ๋ด์.
-- ์ํ --
local NewDateTime = DateTime.new(2022, 06, 30, 10, 30, 05)
print(NewDateTime.Minute)
Second
Second๋ฅผ ๋ํ๋ด์.
-- ์ํ --
local NewDateTime = DateTime.new(2022, 06, 30, 10, 30, 05)
print(NewDateTime.Second)
์์ฑ์
DateTime new()
DateTime๋ฅผ ์์ฑํด์.
DateTime new()
DateTime๋ฅผ Year, Month, Day, Hour, Minute, Second ๊ฐ์ผ๋ก ์ธํ ํ์ฌ ์์ฑํด์
-- ์ํ --
local NewDateTime = DateTime.new(2022, 06, 30, 10, 30, 05)
ํจ์
string ToString()
์๊ฐ์ ์ํ๋ ํฌ๋งท ํ์ ์ผ๋ก ์ถ๋ ฅํ ์ ์์ด์. AM, PM ๊ตฌํ๋ ํฌ๋งท : (%a : am, pm) , (%A : AM, PM) ์ผ ๊ตฌํ๋ ํฌ๋งท : (%d : ํด๋น ๋ฌ์ 1 ~ 31์ผ), (%D : 1์ 1์ผ ~ ํ์ฌ ๋ ์ง ๊น์ง ํ๋ฅธ ์ผ์) ๋ฌ ๊ตฌํ๋ ํฌ๋งท : %m ๋ ๋ ๊ตฌํ๋ ํฌ๋งท : (%y : ํ์ฌ ๋ ๋๋ฅผ 100์ผ๋ก ๋๋ ๋๋จธ์ง ์ 2022 -> 22), (%Y : ํ์ฌ ๋ ๋) ์๊ฐ ๊ตฌํ๋ ํฌ๋งท : (%h : AM, PM ์ ๋ฐ๋ผ 1 ~ 12 ๊น์ง์ ์๊ฐ), (%H : 0 ~ 23) ๋ถ ๊ตฌํ๋ ํฌ๋งท : %M ์ด ๊ตฌํ๋ ํฌ๋งท : (%s : MiliSecond), (%S : Second ) ํน์๋ฌธ์ . ,-, " " ๋ฑ ์ํ์๋ ์์น์ ๋ฃ์ผ์๋ฉด ๋ฉ๋๋ค. ๊ธฐ๋ณธ ํ์ ์ ("%Y.%m.%d-%H.%M.%S") ์ ๋๋ค.
-- ์ํ --
local NewDateTime = DateTime.new(2022, 06, 30, 10, 30, 05)
local stringDate = NewDateTime:ToString("%Y.%m.%d-%H.%M.%S %A")
print(stringDate)
Last updated
Was this helpful?