LogoLogo
Scripting DocsSupport
Scripting
Scripting
  • Sinespace Scripting Documentation
  • Client Scripting
    • Viewer
      • SDialogues
      • SInput
      • SShared
      • SUI
    • Network
      • SChat
      • SNetwork
      • SPhotos
      • SVideos
      • SWebService
    • Player
      • SEconomy
      • SGroup
      • SInventory
      • SProfile
      • SQuests
    • Region
      • SCameraManager
      • SGrid
      • SHost
      • SPersistence
      • SPhysics
      • SPostFX
      • SScene
      • SScript
      • SRenderSettings
    • Components
      • SAnimation
      • SAnimator
      • SAudioReactiveAnimation
      • SAudioReactiveBase
      • SAudioReactiveLight
      • SAudioReactiveMaterial
      • SAudioReactiveParticleSystem
      • SAudioReactiveTransform
      • SAudioSource
      • SBoxCollider
      • SBrowserSurface
      • SCamera
      • SCanvasGroup
      • SCapsuleCollider
      • SCharacterController
      • SClickable
      • SCloth
      • SCollider
      • SContentSizeFitter
      • SEmbeddedVideo
      • SEventCalendar
      • SFurniture
      • SGraphicRaycaster
      • SHingeJoint
      • SLight
      • SLineRenderer
      • SMeshRenderer
      • SModularVehicle
      • SNavMeshAgent
      • SNavMeshObstacle
      • SNetworking
      • SParticleSystem
      • SPlayableDirector
      • SPostProcessVolume
      • SRectTransform
      • SReflectionProbe
      • SRenderer
      • SRigidbody
      • SRoomFloor
      • SSceneBackgroundMusic
      • SScriptingData
      • SScriptingEvents
      • SScriptingResources
      • SScriptingRuntime
      • SSeat
      • SSkinnedMeshRenderer
      • SSphereCollider
      • SStateMachine
      • STerrain
      • STrailRenderer
      • SUIButton
      • SUICanvas
      • SUIDropdown
      • SUIImage
      • SUIInputField
      • SUILayout
      • SUIRawImage
      • SUIScrollbar
      • SUISlider
      • SUIText
      • SUIToggle
      • SUIToolTipHint
      • SVirtualCamera
      • SVoiceZone
    • Types
      • SAnimationState
      • SAnimatorStateInfo
      • SAvatar
      • SAvatarAppearance
      • SChatMessage
      • SColor
      • SCommandBuffer
      • SDateTime
      • SGameObject
      • SGenre
      • SGroupInfo
      • SInventoryItem
      • SJointLimits
      • SJointMotor
      • SJointSpring
      • SLandmark
      • SLayerMask
      • SMaterial
      • SMath
      • SMusicDirectory
      • SMusicStation
      • SMusicStationList
      • SNetworkMessageLua
      • SOutfit
      • SParticle
      • SPhysicsHit
      • SPublicRegion
      • SQuaternion
      • SRay
      • SRect
      • SResource
      • SScore
      • SScoreRank
      • SString
      • SSubRegion
      • STrackInfo
      • STuneIn
      • SUIRaycastResult
      • SUserRegions
      • SVector
      • SUserProfile
      • SSocialMedia
      • SWebResponse
  • Server Scripting
    • Library
      • SMath
    • Network
      • SShared
      • SWebservice
    • Region
      • SAvatar
      • SCell
      • SObject
      • SParcel
      • SParcelManager
      • SRegionScript
      • SScene
    • Storage
      • SDatabase
  • Guides
    • Persistence
    • Server Scripts
  • Sample Projects
    • Smart Lights
    • Trivia Box
  • Changelog
    • API Changelog
  • Support
    • Report An Issue
Powered by GitBook

Sinespace® is a registered trademark of Sine Wave Entertainment Ltd, All Rights Reserved.

On this page
  • Index
  • Functions Index
  • Properties Index
  • Functions
  • Equals
  • ComparesTo
  • FormatLocal
  • FunctionName
  • Regional
  • FormatRegional
  • AddYears
  • AddMonths
  • AddDays
  • AddHours
  • AddMinutes
  • AddSeconds
  • AddMilliseconds
  • Now
  • Server
  • Parse
  • IsLeapYear
  • DaysInMonth
  • Properties
  • Year
  • Month
  • Day
  • Hour
  • Minute
  • Second
  • Millisecond
  • Local
  • Global
  • UnixTime
  • IsDaylightSavingTime

Was this helpful?

Export as PDF
  1. Client Scripting
  2. Types

SDateTime

Index

Functions Index

Function Name

Static Functions

Properties Index

Property Name

Functions

Equals

bool Equals (SDateTime other)

Returns true if the datetimes are same.

Parameter
Type
Description

ATargetDateTime = DateTime.Now().AddMinutes(5)
AreEqual = ATargetDateTime.Equals(DateTime.Now())

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

ATargetDateTime = DateTime.Now().AddMinutes(5)
AreEqual = ATargetDateTime.ComparesTo(DateTime.Now())

FormatLocal

string FormatLocal (string format)

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

Parameter
Type
Description

format

string

See below for examples

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

string FormatGlobal (string format)

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

Parameter
Type
Description

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

string Regional (string region)

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

Parameter
Type
Description

region

string

stringTimeRegional = DateTime.Now().Regional('en-us')

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

region

string

format

string

See below

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

SDateTime AddYears (int amount)

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

Parameter
Type
Description

date5YearsLater = DateTime.Now().AddYears(5)

AddMonths

SDateTime AddMonths (int amount)

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

Parameter
Type
Description

date5MonthsLater = DateTime.Now().AddMonths(5)

AddDays

SDateTime AddDays (double amount)

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

Parameter
Type
Description

date5DaysLater = DateTime.Now().AddDays(5)

AddHours

SDateTime AddHours (double amount)

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

Parameter
Type
Description

date5HoursLater = DateTime.Now().AddHours(5)

AddMinutes

SDateTime AddMinutes (double amount)

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

Parameter
Type
Description

date5MinutesLater = DateTime.Now().AddMinutes(5)

AddSeconds

SDateTime AddSeconds (double amount)

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

Parameter
Type
Description

date5SecondsLater = DateTime.Now().AddSeconds(5)

AddMilliseconds

SDateTime AddMilliseconds (double amount)

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

Parameter
Type
Description

date5MillisecondsLater = DateTime.Now().AddMilliseconds(5)

Now

static SDateTime Now()

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

Parameter
Type
Description

localDateTime = DateTime.Now()

Server

static SDateTime Server ()

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

Parameter
Type
Description

serverDateTime = DateTime.Server()

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

parseDateTime = DateTime.Parse('10/3/2022 1:26:02 PM')

IsLeapYear

static bool IsLeapYear (int year)

Return true if the specified year is a leap year.

Parameter
Type
Description

isLeapYear = DateTime.IsLeapYear(2024)

DaysInMonth

static int DaysInMonth (int year, int month)

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

Parameter
Type
Description

isLeapYear = DateTime.DaysInMonth(2022, 8)

Properties

Year

int Year get

Get the independent time unit property of the SDateTime object.

currentYear = DateTime.Now().Year

Month

int Month get

Property Description

currentMonth = DateTime.Now().Month

Day

int Day get

Property Description

currentDay = DateTime.Now().Day

Hour

int Hour get

Property Description

currentHour = DateTime.Now().Hour

Minute

int Minute get

Property Description

currentMinute = DateTime.Now().Minute

Second

int Second get

Property Description

currentSecond = DateTime.Now().Second

Millisecond

int Millisecond get

Property Description

currentMillisecond = DateTime.Now().Millisecond

Local

string Local get

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

currentTimeStringLocal = DateTime.Now().Local

Global

string Global get

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

currentTimeStringGlobal = DateTime.Now().Global

UnixTime

int UnixTime get

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

currentUnixTime = DateTime.Now().UnixTime

IsDaylightSavingTime

bool IsDaylightSavingTime get

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

isCurrentTimeDaylightSaving = DateTime.Now().IsDaylightSavingTime
PreviousSCommandBufferNextSGameObject

Last updated 2 years ago

Was this helpful?

bool (SDateTime other)

int (SDateTime other)

string (string format)

string (string format)

string (string region)

string (string region, string format)

SDateTime (int amount)

SDateTime (int amount)

SDateTime (double amount)

SDateTime (double amount)

SDateTime (double amount)

SDateTime (double amount)

SDateTime (double amount)

static SDateTime ()

static SDateTime ()

static SDateTime (string input)

static bool (int year)

static int (int year, int month)

int get

int get

int get

int get

int get

int get

int get

string get

string get

int get

bool get

Equals
ComparesTo
FormatLocal
FormatGlobal
Regional
FormatRegional
AddYears
AddMonths
AddDays
AddHours
AddMinutes
AddSeconds
AddMilliseconds
Now
Server
Parse
IsLeapYear
DaysInMonth
Year
Month
Day
Hour
Minute
Second
Millisecond
Local
Global
UnixTime
IsDaylightSavingTime
List available here
List available here