SDateTime
| Fonction | Equals | Returns true if the datetimes are same. |
| Fonction | 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. |
| Fonction | FormatLocal | Outputs a custom formatted string with the date and time according to local language rules. |
| Fonction | FunctionName | Outputs a custom formatted string with the date and time according to global rules (culture invariant). |
| Fonction | Regional | Outputs a string with the date and time formatted according to specific regional rules. |
| Fonction | FormatRegional | Outputs a custom formatted string with the date and time according to specific regional rules. |
| Fonction | AddYears | Return a new SDateTime that is the current date time + amount years. |
| Fonction | AddMonths | Return a new SDateTime that is the current date time + amount months. |
| Fonction | AddDays | Return a new SDateTime that is the current date time + amount days. |
| Fonction | AddHours | Return a new SDateTime that is the current date time + amount hours. |
| Fonction | AddMinutes | Return a new SDateTime that is the current date time + amount minutes. |
| Fonction | AddSeconds | Return a new SDateTime that is the current date time + amount seconds. |
| Fonction | AddMilliseconds | Return a new SDateTime that is the current date time + amount milliseconds. |
| Fonction | Now | Creates a new SDateTime object equal to the current local time. |
| Fonction | Server | Creates a new SDateTime object equal to the current server time. |
| Fonction | Parse | Creates a new SDateTime object by attempting to parse a string input. |
| Fonction | IsLeapYear | Return true if the specified year is a leap year. |
| Fonction | DaysInMonth | Return the number of days in the given month for the given year. |
| Propriété | Year | Get the independent time unit property of the SDateTime object. |
| Propriété | Month | – |
| Propriété | Day | – |
| Propriété | Hour | – |
| Propriété | Minute | – |
| Propriété | Second | – |
| Propriété | Millisecond | – |
| Propriété | Local | Outputs a string with the date and time formatted according to local language rules. |
| Propriété | Global | Outputs a string with the date and time formatted according to global rules (culture invariant). |
| Propriété | UnixTime | Return this time in Unix time, the number of seconds since Jan 1st, 1970. |
| Propriété | IsDaylightSavingTime | Indicates whether this instance of DateTime is within the daylight saving time range for the current time zone. |
Fonctions
Equals
Returns true if the datetimes are same.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| other | SDateTime | – |
Valeurs de retour
bool
Exemple
``` 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.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| other | SDateTime | – |
Valeurs de retour
int
Exemple
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.
Paramètres
| Paramètre | Type | Description |
|---|---|---|
| format | string | See below for examples |
Valeurs de retour
string
Exemple
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).
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| format | string | – |
Valeurs de retour
string
Exemple
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.
Paramètres
| Paramètre | Type | Description |
|---|---|---|
| region | string | List available here |
Valeurs de retour
string
Exemple
stringTimeRegional = DateTime.Now().Regional('en-us')
FormatRegional
Outputs a custom formatted string with the date and time according to specific regional rules.
Paramètres
| Paramètre | Type | Description |
|---|---|---|
| region | string | List available here |
| format | string | See below |
Valeurs de retour
string
Exemple
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.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| amount | int | – |
Valeurs de retour
SDateTime
Exemple
date5YearsLater = DateTime.Now().AddYears(5)
AddMonths
Return a new SDateTime that is the current date time + amount months.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| amount | int | – |
Valeurs de retour
SDateTime
Exemple
date5MonthsLater = DateTime.Now().AddMonths(5)
AddDays
Return a new SDateTime that is the current date time + amount days.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| amount | double | – |
Valeurs de retour
SDateTime
Exemple
date5DaysLater = DateTime.Now().AddDays(5)
AddHours
Return a new SDateTime that is the current date time + amount hours.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| amount | double | – |
Valeurs de retour
SDateTime
Exemple
date5HoursLater = DateTime.Now().AddHours(5)
AddMinutes
Return a new SDateTime that is the current date time + amount minutes.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| amount | double | – |
Valeurs de retour
SDateTime
Exemple
date5MinutesLater = DateTime.Now().AddMinutes(5)
AddSeconds
Return a new SDateTime that is the current date time + amount seconds.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| amount | double | – |
Valeurs de retour
SDateTime
Exemple
date5SecondsLater = DateTime.Now().AddSeconds(5)
AddMilliseconds
Return a new SDateTime that is the current date time + amount milliseconds.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| amount | double | – |
Valeurs de retour
SDateTime
Exemple
date5MillisecondsLater = DateTime.Now().AddMilliseconds(5)
Now
Creates a new SDateTime object equal to the current local time.
Valeurs de retour
SDateTime
Exemple
localDateTime = DateTime.Now()
Server
Creates a new SDateTime object equal to the current server time.
Valeurs de retour
SDateTime
Exemple
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.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| input | string | – |
Valeurs de retour
SDateTime
Exemple
parseDateTime = DateTime.Parse('10/3/2022 1:26:02 PM')
IsLeapYear
Return true if the specified year is a leap year.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| year | int | – |
Valeurs de retour
bool
Exemple
isLeapYear = DateTime.IsLeapYear(2024)
DaysInMonth
Return the number of days in the given month for the given year.
Paramètres
| Nom | Type | Valeur par défaut |
|---|---|---|
| year | int | – |
| month | int | – |
Valeurs de retour
int
Exemple
isLeapYear = DateTime.DaysInMonth(2022, 8)
Propriétés
YearLecture seule
Get the independent time unit property of the SDateTime object.
Exemple
currentYear = DateTime.Now().Year
MonthLecture seule
Exemple
currentMonth = DateTime.Now().Month
DayLecture seule
Exemple
currentDay = DateTime.Now().Day
HourLecture seule
Exemple
currentHour = DateTime.Now().Hour
MinuteLecture seule
Exemple
currentMinute = DateTime.Now().Minute
SecondLecture seule
Exemple
currentSecond = DateTime.Now().Second
MillisecondLecture seule
Exemple
currentMillisecond = DateTime.Now().Millisecond
LocalLecture seule
Outputs a string with the date and time formatted according to local language rules.
Exemple
currentTimeStringLocal = DateTime.Now().Local
GlobalLecture seule
Outputs a string with the date and time formatted according to global rules (culture invariant).
Exemple
currentTimeStringGlobal = DateTime.Now().Global
UnixTimeLecture seule
Return this time in Unix time, the number of seconds since Jan 1st, 1970.
Exemple
currentUnixTime = DateTime.Now().UnixTime
IsDaylightSavingTimeLecture seule
Indicates whether this instance of DateTime is within the daylight saving time range for the current time zone.
Exemple
isCurrentTimeDaylightSaving = DateTime.Now().IsDaylightSavingTime



