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?