Lua common time function usage example
Updated: April 21, 2015 09:12:41 Submission: junjie
This article mainly introduces Lua's commonly used time function usage examples. This article directly gives usage code examples and attaches detailed comments. Which copy should be used? Friends who need it can refer to it.
-- Get current Greenwich time print(()) -- Get the string representation of the current time,Like:11/28/08 10:28:37 print(()) -- Get the string representation of the current date,Like:11/28/08 print(("%x", ())) -- Get the string representation of the current time,Like:10:28:37 print(("%X", ())) -- Get the string representation of the current time,Like:10/10/13 10:28:37 print(("%c", ())) -- Get the string representation of the current time,Like:2013-10-10 10:28:37 print(("%Y-%m-%d %H:%M:%S", ())) --The function returns to execute the programCPUThe number of clock seconds spent local x1 = () local s = 0 for i = 1, 10000000 do s = s + i end local x2 = () print(("elapsed time: %.2f\n", x2 - x1)) local T2009_StartTime = { year=2013, month=2, day=9, hour=0, min=0, sec=0 } local T2009_EndTime = { year=2013, month=2, day=17, hour=23, min=59, sec=59 } T2009_AvtivityTime = { startTime = (T2009_StartTime), endTime = (T2009_EndTime) } print('The event was successful with the event:' .. ('%c', T2009_AvtivityTime.startTime) .. '~' .. ('%c', T2009_AvtivityTime.endTime)) temp = ("*t", ()) print(temp) --[[A table will be generated {year = 1998, month = 9, day = 16, yday = 259, wday = 4, hour = 23, min = 48, sec = 10, isdst = false} --]]
Related Articles
Implement StringBuffer function in Lua
This article mainly introduces the implementation of StringBuffer function in Lua. This article gives the implementation code and call code. Friends who need it can refer to it.2014-11-11A brief analysis of exception handling in Lua programming
This article mainly introduces a brief analysis of exception handling in Lua programming, which is the basic knowledge in Lua's introductory learning. Friends who want it can refer to it.2015-05-052048 game made by lua+love2d
What I have shared with you before is a super simple version of the 2048 mini game implemented using lua. Today we will add the love2d game engine to create a PC version of the 2048 game. Friends, read this article carefully.2015-03-03Closure Study Notes in Lua
This article mainly introduces the closure learning notes in Lua. Closures are code blocks that can contain free (not bound to a specific object) variable; these variables are not defined within this code block or in any global context, but are defined in the environment where the code block is defined (local variables). Friends who need it can refer to it2014-12-12Lua tutorial weak reference table
This article mainly introduces the weak citation table in Lua tutorial. This article explains the defects of automatic memory management, weak citation table, and three forms of weak citation. Friends who need it can refer to it.2014-09-09Example of method to convert Lua Table to C# Dictionary
This article mainly introduces relevant materials about Lua Table to C# Dictionary. The example code in the article is introduced in detail, which has certain reference learning value for everyone's study or work. Friends who need it, please learn with the editor below.2018-03-03Lua UnPack function usage example
This article mainly introduces the Lua UnPack function usage example. Unpack accepts an array (table) as a parameter and returns all elements of the array from subscript 1 by default. Friends who need it can refer to it.2015-04-04Lua minimalist guide to getting started: global variables
This article mainly introduces Lua's minimalist introduction guide: global variables. This article explains global variables, _ENV and other content. Friends who need it can refer to it.2014-10-10Introduction to capture mechanism and conversion techniques in Lua
This article mainly introduces the capture mechanism and conversion techniques in Lua. Capture is a mechanism like this: you can use part of the pattern string to match part of the target string, enclose the pattern you want to capture in parentheses, and specify a capture. Friends who need it can refer to it.2014-11-11Example explanation of functions, variable parameters, local functions, tail recursive optimization and other examples in Lua
This article mainly introduces examples such as functions, variable parameters, local functions, tail recursive optimization in Lua. Friends who need it can refer to it.2014-09-09