Difference between revisions of "DateTime"

From MiniScript Wiki
Jump to navigation Jump to search
(Initial Page)
 
m (Added Parameters)
Line 12: Line 12:
 
| [[dateTime.now|now(format)]] || Return the current date/time as a string. By default, format = "yyyy-MM-dd HH:mm:ss".
 
| [[dateTime.now|now(format)]] || Return the current date/time as a string. By default, format = "yyyy-MM-dd HH:mm:ss".
 
|-
 
|-
| [[dateTime.str|str]] || Convert a date (string or number) to a string with the given format. By default, format = "yyyy-MM-dd HH:mm:ss".
+
| [[dateTime.str|strdate, format)]] || Convert a date (string or number) to a string with the given format. By default, format = "yyyy-MM-dd HH:mm:ss".
 
|-
 
|-
| [[dateTime.val|val]] || Convert a date string to a number. By default, format = "yyyy-MM-dd HH:mm:ss".  If no date string is given, returns the current time (same as nowVal).
+
| [[dateTime.val|val(dateStr)]] || Convert a date string to a number. By default, format = "yyyy-MM-dd HH:mm:ss".  If no date string is given, returns the current time (same as nowVal).
 
|-
 
|-
| [[dateTime.year|year]] || Get the year of the given date, as a number.
+
| [[dateTime.year|year(date)]] || Get the year of the given date, as a number.
 
|-
 
|-
| [[dateTime.month|month]] || Get the month of the given date, as a number from 1 to 12.
+
| [[dateTime.month|month(date)]] || Get the month of the given date, as a number from 1 to 12.
 
|-
 
|-
| [[dateTime.day|day]] || Get the day of the given date, as a number from 1 to 31.
+
| [[dateTime.day|day(date)]] || Get the day of the given date, as a number from 1 to 31.
 
|-
 
|-
| [[dateTime.hour|hour]] || Get the hour of the given date/time, as a number from 0 to 23.
+
| [[dateTime.hour|hour(date)]] || Get the hour of the given date/time, as a number from 0 to 23.
 
|-
 
|-
| [[dateTime.minute|minute]] || Get the minute of the given date/time, as a number from 0 to 59.
+
| [[dateTime.minute|minute(date)]] || Get the minute of the given date/time, as a number from 0 to 59.
 
|-
 
|-
| [[dateTime.second|second]] || Get the second of the given date, as a number from 0 to 59.
+
| [[dateTime.second|second(date)]] || Get the second of the given date, as a number from 0 to 59.
 
|-
 
|-
| [[dateTime.weekday|weekday]] || Get the day of the week for the given date, from 0 (Sunday) to 6 (Saturday).
+
| [[dateTime.weekday|weekday(date)]] || Get the day of the week for the given date, from 0 (Sunday) to 6 (Saturday).
 
|}
 
|}
  

Revision as of 07:43, 31 March 2025

Mini Micro supports dates/times in two different formats: as a string (by default in SQL format), and as a number of seconds since a reference date (Jan 01, 2000). The numeric format is useful for doing date/time calculations, like finding the amount of time between two dates, or adding some amount of time to a starting date/time.

For details on the format specifiers: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings .

Functions

Name Description
nowVal Get the current date/time, as a number.
now(format) Return the current date/time as a string. By default, format = "yyyy-MM-dd HH:mm:ss".
strdate, format) Convert a date (string or number) to a string with the given format. By default, format = "yyyy-MM-dd HH:mm:ss".
val(dateStr) Convert a date string to a number. By default, format = "yyyy-MM-dd HH:mm:ss". If no date string is given, returns the current time (same as nowVal).
year(date) Get the year of the given date, as a number.
month(date) Get the month of the given date, as a number from 1 to 12.
day(date) Get the day of the given date, as a number from 1 to 31.
hour(date) Get the hour of the given date/time, as a number from 0 to 23.
minute(date) Get the minute of the given date/time, as a number from 0 to 59.
second(date) Get the second of the given date, as a number from 0 to 59.
weekday(date) Get the day of the week for the given date, from 0 (Sunday) to 6 (Saturday).

Properties

Name Description
weekdayNames Weekday name abbreviations, in the order returned by the weekday function. DO NOT CHANGE THESE, or the weekday function will no longer work.

Example

	import "dateTime"

	print "It is now: " + dateTime.now