All pages
Powered by GitBook
1 of 1

Loading...

SDateTime

Index

Functions Index

Function Name

Properties Index

Property Name

Functions

Equals

bool Equals (SDateTime other)

Returns true if the datetimes are same.

Parameter
Type
Description

ComparesTo

int ComparesTo (SDateTime other)

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.

Parameter
Type
Description

FormatLocal

string FormatLocal (string format)

Outputs a custom formatted string with the date and time according to local language rules.

Parameter
Type
Description

FunctionName

string FormatGlobal (string format)

Outputs a custom formatted string with the date and time according to global rules (culture invariant).

Parameter
Type
Description

Regional

string Regional (string region)

Outputs a string with the date and time formatted according to specific regional rules.

Parameter
Type
Description

FormatRegional

string FormatRegional (string region, string format)

Outputs a custom formatted string with the date and time according to specific regional rules.

Parameter
Type
Description

AddYears

SDateTime AddYears (int amount)

Return a new SDateTime that is the current date time + amount years.

Parameter
Type
Description

AddMonths

SDateTime AddMonths (int amount)

Return a new SDateTime that is the current date time + amount months.

Parameter
Type
Description

AddDays

SDateTime AddDays (double amount)

Return a new SDateTime that is the current date time + amount days.

Parameter
Type
Description

AddHours

SDateTime AddHours (double amount)

Return a new SDateTime that is the current date time + amount hours.

Parameter
Type
Description

AddMinutes

SDateTime AddMinutes (double amount)

Return a new SDateTime that is the current date time + amount minutes.

Parameter
Type
Description

AddSeconds

SDateTime AddSeconds (double amount)

Return a new SDateTime that is the current date time + amount seconds.

Parameter
Type
Description

AddMilliseconds

SDateTime AddMilliseconds (double amount)

Return a new SDateTime that is the current date time + amount milliseconds.

Parameter
Type
Description

Now

static SDateTime Now()

Creates a new SDateTime object equal to the current local time.

Parameter
Type
Description

Server

static SDateTime Server ()

Creates a new SDateTime object equal to the current server time.

Parameter
Type
Description

Parse

static SDateTime Parse (string input)

Creates a new SDateTime object by attempting to parse a string input. Returns null/nil if the string cannot be parsed.

Parameter
Type
Description

IsLeapYear

static bool IsLeapYear (int year)

Return true if the specified year is a leap year.

Parameter
Type
Description

DaysInMonth

static int DaysInMonth (int year, int month)

Return the number of days in the given month for the given year.

Parameter
Type
Description

Properties

Year

int Year get

Get the independent time unit property of the SDateTime object.

Month

int Month get

Property Description

Day

int Day get

Property Description

Hour

int Hour get

Property Description

Minute

int Minute get

Property Description

Second

int Second get

Property Description

Millisecond

int Millisecond get

Property Description

Local

string Local get

Outputs a string with the date and time formatted according to local language rules.

Global

string Global get

Outputs a string with the date and time formatted according to global rules (culture invariant).

UnixTime

int UnixTime get

Return this time in Unix time, the number of seconds since Jan 1st, 1970.

IsDaylightSavingTime

bool IsDaylightSavingTime get

Indicates whether this instance of DateTime is within the daylight saving time range for the current time zone.

SDateTime (double amount)

Static Functions

static SDateTime ()

static SDateTime ()

static SDateTime (string input)

static bool (int year)

static int (int year, int month)

bool get

bool Equals (SDateTime other)

int ComparesTo (SDateTime other)

string FormatLocal (string format)

string FormatGlobal (string format)

string Regional (string region)

string FormatRegional (string region, string format)

SDateTime AddYears (int amount)

SDateTime AddMonths (int amount)

SDateTime AddDays (double amount)

SDateTime AddHours (double amount)

SDateTime AddMinutes (double amount)

int Year get

int Month get

int Day get

int Hour get

int Minute get

int Second get

int Millisecond get

string Local get

string Global get

format

string

See below for examples

region

string

List available here

region

string

List available here

format

string

See below

SDateTime (double amount)

int get

ATargetDateTime = DateTime.Now().AddMinutes(5)
AreEqual = ATargetDateTime.Equals(DateTime.Now())
ATargetDateTime = DateTime.Now().AddMinutes(5)
AreEqual = ATargetDateTime.ComparesTo(DateTime.Now())
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
    --]]
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
    --]]
stringTimeRegional = DateTime.Now().Regional('en-us')
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
    --]]
date5YearsLater = DateTime.Now().AddYears(5)
date5MonthsLater = DateTime.Now().AddMonths(5)
date5DaysLater = DateTime.Now().AddDays(5)
date5HoursLater = DateTime.Now().AddHours(5)
date5MinutesLater = DateTime.Now().AddMinutes(5)
date5SecondsLater = DateTime.Now().AddSeconds(5)
date5MillisecondsLater = DateTime.Now().AddMilliseconds(5)
localDateTime = DateTime.Now()
serverDateTime = DateTime.Server()
parseDateTime = DateTime.Parse('10/3/2022 1:26:02 PM')
isLeapYear = DateTime.IsLeapYear(2024)
isLeapYear = DateTime.DaysInMonth(2022, 8)
currentYear = DateTime.Now().Year
currentMonth = DateTime.Now().Month
currentDay = DateTime.Now().Day
currentHour = DateTime.Now().Hour
currentMinute = DateTime.Now().Minute
currentSecond = DateTime.Now().Second
currentMillisecond = DateTime.Now().Millisecond
currentTimeStringLocal = DateTime.Now().Local
currentTimeStringGlobal = DateTime.Now().Global
currentUnixTime = DateTime.Now().UnixTime
isCurrentTimeDaylightSaving = DateTime.Now().IsDaylightSavingTime
AddSeconds
AddMilliseconds
Now
Server
Parse
IsLeapYear
DaysInMonth
UnixTime
IsDaylightSavingTime