SDateTime
| Function | Equals | Returns true if the datetimes are same. |
| Function | ComparesTo | Compares two datetimes and returns an integer. 0 == identical. greater than 0 == This datetime is greater than other. less than 0 == This datetime is less than other. |
| Function | FormatLocal | Outputs a custom formatted string with the date and time according to local language rules. |
| Function | FunctionName | Outputs a custom formatted string with the date and time according to global rules (culture invariant). |
| Function | Regional | Outputs a string with the date and time formatted according to specific regional rules. |
| Function | FormatRegional | Outputs a custom formatted string with the date and time according to specific regional rules. |
| Function | AddYears | Return a new SDateTime that is the current date time + amount years. |
| Function | AddMonths | Return a new SDateTime that is the current date time + amount months. |
| Function | AddDays | Return a new SDateTime that is the current date time + amount days. |
| Function | AddHours | Return a new SDateTime that is the current date time + amount hours. |
| Function | AddMinutes | Return a new SDateTime that is the current date time + amount minutes. |
| Function | AddSeconds | Return a new SDateTime that is the current date time + amount seconds. |
| Function | AddMilliseconds | Return a new SDateTime that is the current date time + amount milliseconds. |
| Function | Now | Creates a new SDateTime object equal to the current local time. |
| Function | Server | Creates a new SDateTime object equal to the current server time. |
| Function | Parse | Creates a new SDateTime object by attempting to parse a string input. |
| Function | IsLeapYear | Return true if the specified year is a leap year. |
| Function | DaysInMonth | Return the number of days in the given month for the given year. |
| Property | Year | Get the independent time unit property of the SDateTime object. |
| Property | Month | – |
| Property | Day | – |
| Property | Hour | – |
| Property | Minute | – |
| Property | Second | – |
| Property | Millisecond | – |
| Property | Local | Outputs a string with the date and time formatted according to local language rules. |
| Property | Global | Outputs a string with the date and time formatted according to global rules (culture invariant). |
| Property | UnixTime | Return this time in Unix time, the number of seconds since Jan 1st, 1970. |
| Property | IsDaylightSavingTime | Indicates whether this instance of DateTime is within the daylight saving time range for the current time zone. |
Functions
Equals
Returns true if the datetimes are same.
Parameters
| Name | Type | Default |
|---|---|---|
| other | SDateTime | – |
Returns
bool
Example
``` ATargetDateTime = DateTime.Now().AddMinutes(5) AreEqual = ATargetDateTime.Equals(DateTime.Now()) ```
ComparesTo
Compares two datetimes and returns an integer. 0 == identical. greater than 0 == This datetime is greater than other. less than 0 == This datetime is less than other.
Parameters
| Name | Type | Default |
|---|---|---|
| other | SDateTime | – |
Returns
int
Example
ATargetDateTime = DateTime.Now().AddMinutes(5)
AreEqual = ATargetDateTime.ComparesTo(DateTime.Now())
FormatLocal
Outputs a custom formatted string with the date and time according to local language rules.
Parameters
| Parameter | Type | Description |
|---|---|---|
| format | string | See below for examples |
Returns
string
Example
localTimeCustomFormat = DateTime.Now().FormatLocal("dddd, MMMM dd, yyyy h:mm:ss tt")
``` --Example format strings
--[[ format = "dddd, MMMM dd, yyyy h:mm:ss tt" Result: Monday, May 28, 2012 11:35:00 AM
format = "Ldddd, MMMM dd, yyyy" Result: Monday, May 28, 2012
format = "h:mm:ss tt" Result: 11:35:00 AM
format = "MMMM dd" Result: May 28
format = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT" Result: Mon, 28 May 2012 11:35:00 GMT
format = "M/d/yyyy" Result: 5/28/2012
format = "h:mm tt" Result: 11:35 AM
format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss" Result: 2012-05-28T11:35:00
format = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'" Result: 2012-05-28 11:35:00Z
format = "MMMM, yyyy" Result: May, 2012 --]] ```
FunctionName
Outputs a custom formatted string with the date and time according to global rules (culture invariant).
Parameters
| Name | Type | Default |
|---|---|---|
| format | string | – |
Returns
string
Example
GlobalTimeCustomFormat = DateTime.Now().FormatLocal("dddd, MMMM dd, yyyy h:mm:ss tt")
--Example format strings
--[[
format = "dddd, MMMM dd, yyyy h:mm:ss tt"
Result: Monday, May 28, 2012 11:35:00 AM
format = "Ldddd, MMMM dd, yyyy"
Result: Monday, May 28, 2012
format = "h:mm:ss tt"
Result: 11:35:00 AM
format = "MMMM dd"
Result: May 28
format = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT"
Result: Mon, 28 May 2012 11:35:00 GMT
format = "M/d/yyyy"
Result: 5/28/2012
format = "h:mm tt"
Result: 11:35 AM
format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"
Result: 2012-05-28T11:35:00
format = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"
Result: 2012-05-28 11:35:00Z
format = "MMMM, yyyy"
Result: May, 2012
--]]
Regional
Outputs a string with the date and time formatted according to specific regional rules.
Parameters
| Parameter | Type | Description |
|---|---|---|
| region | string | List available here |
Returns
string
Example
stringTimeRegional = DateTime.Now().Regional('en-us')
FormatRegional
Outputs a custom formatted string with the date and time according to specific regional rules.
Parameters
| Parameter | Type | Description |
|---|---|---|
| region | string | List available here |
| format | string | See below |
Returns
string
Example
stringTimeFormatRegional = DateTime.Now().FormatRegional('en-us','dddd, MMMM dd, yyyy h:mm:ss tt')
--Example format strings
--[[
format = "dddd, MMMM dd, yyyy h:mm:ss tt"
Result: Monday, May 28, 2012 11:35:00 AM
format = "Ldddd, MMMM dd, yyyy"
Result: Monday, May 28, 2012
format = "h:mm:ss tt"
Result: 11:35:00 AM
format = "MMMM dd"
Result: May 28
format = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT"
Result: Mon, 28 May 2012 11:35:00 GMT
format = "M/d/yyyy"
Result: 5/28/2012
format = "h:mm tt"
Result: 11:35 AM
format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"
Result: 2012-05-28T11:35:00
format = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"
Result: 2012-05-28 11:35:00Z
format = "MMMM, yyyy"
Result: May, 2012
--]]
AddYears
Return a new SDateTime that is the current date time + amount years.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | int | – |
Returns
SDateTime
Example
date5YearsLater = DateTime.Now().AddYears(5)
AddMonths
Return a new SDateTime that is the current date time + amount months.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | int | – |
Returns
SDateTime
Example
date5MonthsLater = DateTime.Now().AddMonths(5)
AddDays
Return a new SDateTime that is the current date time + amount days.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | double | – |
Returns
SDateTime
Example
date5DaysLater = DateTime.Now().AddDays(5)
AddHours
Return a new SDateTime that is the current date time + amount hours.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | double | – |
Returns
SDateTime
Example
date5HoursLater = DateTime.Now().AddHours(5)
AddMinutes
Return a new SDateTime that is the current date time + amount minutes.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | double | – |
Returns
SDateTime
Example
date5MinutesLater = DateTime.Now().AddMinutes(5)
AddSeconds
Return a new SDateTime that is the current date time + amount seconds.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | double | – |
Returns
SDateTime
Example
date5SecondsLater = DateTime.Now().AddSeconds(5)
AddMilliseconds
Return a new SDateTime that is the current date time + amount milliseconds.
Parameters
| Name | Type | Default |
|---|---|---|
| amount | double | – |
Returns
SDateTime
Example
date5MillisecondsLater = DateTime.Now().AddMilliseconds(5)
Now
Creates a new SDateTime object equal to the current local time.
Returns
SDateTime
Example
localDateTime = DateTime.Now()
Server
Creates a new SDateTime object equal to the current server time.
Returns
SDateTime
Example
serverDateTime = DateTime.Server()
Parse
Creates a new SDateTime object by attempting to parse a string input. Returns null/nil if the string cannot be parsed.
Parameters
| Name | Type | Default |
|---|---|---|
| input | string | – |
Returns
SDateTime
Example
parseDateTime = DateTime.Parse('10/3/2022 1:26:02 PM')
IsLeapYear
Return true if the specified year is a leap year.
Parameters
| Name | Type | Default |
|---|---|---|
| year | int | – |
Returns
bool
Example
isLeapYear = DateTime.IsLeapYear(2024)
DaysInMonth
Return the number of days in the given month for the given year.
Parameters
| Name | Type | Default |
|---|---|---|
| year | int | – |
| month | int | – |
Returns
int
Example
isLeapYear = DateTime.DaysInMonth(2022, 8)
Properties
YearRead only
Get the independent time unit property of the SDateTime object.
Example
currentYear = DateTime.Now().Year
MonthRead only
Example
currentMonth = DateTime.Now().Month
DayRead only
Example
currentDay = DateTime.Now().Day
HourRead only
Example
currentHour = DateTime.Now().Hour
MinuteRead only
Example
currentMinute = DateTime.Now().Minute
SecondRead only
Example
currentSecond = DateTime.Now().Second
MillisecondRead only
Example
currentMillisecond = DateTime.Now().Millisecond
LocalRead only
Outputs a string with the date and time formatted according to local language rules.
Example
currentTimeStringLocal = DateTime.Now().Local
GlobalRead only
Outputs a string with the date and time formatted according to global rules (culture invariant).
Example
currentTimeStringGlobal = DateTime.Now().Global
UnixTimeRead only
Return this time in Unix time, the number of seconds since Jan 1st, 1970.
Example
currentUnixTime = DateTime.Now().UnixTime
IsDaylightSavingTimeRead only
Indicates whether this instance of DateTime is within the daylight saving time range for the current time zone.
Example
isCurrentTimeDaylightSaving = DateTime.Now().IsDaylightSavingTime



