Clarification of os.date()
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Clarification of os.date()

Started by Herodes, 24 September, 2006, 15:20:24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Herodes

Many of you scripters out there are using the os.date function from the os lib of Lua in PtokaX...
There goes the manual explanation...

Quote from: The 5.1 Lua Manualos.date ( [ format [ , time ] ] )

Returns a string or a table containing date and time, formatted according to the given string format.

If the time argument is present, this is the time to be formatted (see the os.time function for a description of this value). Otherwise, date formats the current time.

If format starts with '!', then the date is formatted in Coordinated Universal Time. After this optional character, if format is the string "*t", then date returns a table with the following fields: year (four digits), month (1--12), day (1--31), hour (0--23), min (0--59), sec (0--61), wday (weekday, Sunday is 1), yday (day of the year), and isdst (daylight saving flag, a boolean).

If format is not "*t", then date returns the date as a string, formatted according to the same rules as the C function strftime.

When called without arguments, date returns a reasonable date and time representation that depends on the host system and on the current locale (that is, os.date() is equivalent to os.date("%c")).

Notice the vague part!

"If format is not "*t", then date returns the date as a string, formatted according to the same rules as the C function strftime."

I was really confused at this part myself when trying to get to know the os.date function,... I was looking for what this func can take,...
and I found it :) there you go the complete proper string formations of os.date():


"%a"The abbreviated weekday name. Example: Thu.
"%A"The full weekday name. Example: Thursday.
"%b"The abbreviated month name. Example: Sep.
"%B"The full month name. Example: September.
"%dThe two-digit day of the month padded with leading zeroes if applicable. Example: 09.
"%e"The day of the month space padded if applicable. Example: 9.
"%H"The two-digit military time hour padded with a zero if applicable. Example: 16.
"%I"The two-digit hour on a 12-hour clock padded with a zero if applicable. Example: 04.
"%j"The three-digit day of the year padded with leading zeroes if applicable. Example: 040.
"%k"The two-digit military time hour padded with a space if applicable. Example: 9.
"%l"The hour on a 12-hour clock padded with a space if applicable. Example: 4.
"%m"The two-digit month padded with a leading zero if applicable. Example: 09.
"%M"The two-digits minute padded with a leading zero if applicable. Example: 02.
"%p"Either AM or PM. Language dependent.
"%S"The two-digit second padded with a zero if applicable. Example: 04.
"%w"The numeric day of the week ranging from 0 to 6 where 0 is Sunday. Example: 0.
"%x"The language-aware standard date representation. For most languages, this is just the same as %B %d, %Y. Example: September 06, 2002.
"%X"The language-aware time representation. For most languages, this is just the same as %I:%M %p. Example: 04:31 PM.
"%y"The two-digit year padded with a leading zero if applicable. Example: 01.
"%Y"The four-digit year. Example: 2001.

Now you are a C programmer too!! :)

bastya_elvtars

Could you please run a wikify() on this? :)
Everything could have been anything else and it would have just as much meaning.


SMF spam blocked by CleanTalk