Difference between revisions of "DateTime"
Jump to navigation
Jump to search
m (Added Parameters) |
m |
||
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| | + | | [[dateTime.str|str(date, 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(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.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). |
Latest revision as of 07:44, 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". |
str(date, 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