Date/Time functions
ConvertToDateTime
Declaration
DateTime ConvertToDateTime(string timestamp, string cultureName)
Description
Converts a string into a DateTime object.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
timestamp
|
String to be converted. |
cultureName
|
Culture-specific formatting information. For example, "en-US", "ru-RU", or "ja-JP". |
Return Value
A DateTime representation of the string.
CreateDateTime
Declaration
DateTime CreateDateTime()
Description
Creates a new date-time object representing the current time and date.
Supported Runtime Versions
1.0, 2.0, 3.0, 4.0, 5.0
Parameters
The function has no parameters.
Return Value
Current time and date as date-time object.
CreateDateTime
Declaration
DateTime CreateDateTime(int year, int month, int day, int hour, int minute, int second)
Description
Creates a new date-time object representing the current time and date.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
year
|
The year of the date. |
month
|
The month of the date. |
day
|
The day of the date. |
hour
|
The hour of the date. |
minute
|
The minute of the date. |
second
|
The second of the date. |
Return Value
A date-time object representing the specified values.
DayOfWeek
Declaration
int DayOfWeek(DateTime dateTime)
Description
Receives the day of the week represented by a DateTime object.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
dateTime
|
The DateTime object to receive the day of the week from. |
Return Value
The day of the week represented by the DateTime object. 0=Sunday, ..., 6=Saturday.
DaysInMonth
Declaration
int DaysInMonth(int year, int month)
Description
Returns the number of days in the specified month and year.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
year
|
The year. |
month
|
The month (a number ranging from 1 to 12). |
Return Value
The number of days in month for the specified year.
GetDateAsString
Declaration
string GetDateAsString(DateTime dateTime)
Description
Returns the date part of a date-time object as a string.
Supported Runtime Versions
1.0, 2.0, 3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
dateTime
|
The date-time object to return the date part for. |
Return Value
Date part of the date-time object.
GetDateAsString
Declaration
string GetDateAsString(DateTime dateTime, string culture)
Description
Returns the date part of a date-time object as a string formatted with the standard short date format (en-us: month/day/year).
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
dateTime
|
The date-time object to return the date part for. |
culture
|
The language culture name (e.g. "en" or "en-US") of the culture to convert to as specified by Microsoft. You can use country-specific cultures. |
Return Value
Date part of the date-time object.
GetDateTimeAsSortableString
Declaration
string GetDateTimeAsSortableString(DateTime dateTime)
Description
Returns the DateTime object as a sortable, culture-independent string of format YYYY/MM/DD-HH:MM:SS. This can be used generally to sort and compare DateTime objects.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
dateTime
|
The date-time object to convert. |
Return Value
Time part of the date-time object.
GetDateTimeAsString
Declaration
string GetDateTimeAsString(DateTime dateTime, string format)
Description
Returns the date-time object as a string converted with the specified format. See Microsoft .Net date and time format strings. You can use all standard and custom format strings.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
dateTime
|
The date-time object to convert. |
format
|
The date-time format string to convert with. |
Return Value
Time part of the date-time object.
GetDateTimeAsString
Declaration
string GetDateTimeAsString(DateTime dateTime, string format, string culture)
Description
Returns the date-time object as a string converted with the specified format and culture. See Microsoft .Net date and time format strings. You can use all standard and custom format strings.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
dateTime
|
The date-time object to convert. |
format
|
The date-time format string to convert with. |
culture
|
The language culture name (e.g. "en" or "en-US") of the culture to convert to as specified by Microsoft. You can use country-specific cultures. |
Return Value
Time part of the date-time object.
GetDurationAsDouble
Declaration
double GetDurationAsDouble(DateTime start, DateTime end)
Description
Returns the duration (in seconds) between two date-time objects.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
start
|
Start of the period to get the duration for. |
end
|
End of the period to get the duration for. |
Return Value
The duration (in seconds) between start and end.
GetDurationAsString
Declaration
string GetDurationAsString(DateTime start, DateTime end)
Description
Returns the duration (in seconds) between two date-time objects as a string.
Supported Runtime Versions
1.0, 2.0, 3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
start
|
Start of the period to get the duration for. |
end
|
End of the period to get the duration for. |
Return Value
The duration (in seconds) between start and end.
GetDurationInMilliseconds
Declaration
double GetDurationInMilliseconds(DateTime start, DateTime end)
Description
Returns the duration (in milliseconds) between two date-time objects.
Supported Runtime Versions
5.0
Parameters
|
Description |
---|---|
start
|
Start of the period to get the duration for. |
end
|
End of the period to get the duration for. |
Return Value
The duration (in milliseconds) between start and end.
GetTimeAsString
Declaration
string GetTimeAsString(DateTime dateTime)
Description
Returns the time part of a date-time object as a string.
Supported Runtime Versions
1.0, 2.0, 3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
dateTime
|
The date-time object to return the time part for. |
Return Value
Time part of the date-time object.
GetTimeAsString
Declaration
string GetTimeAsString(DateTime dateTime, string culture)
Description
Returns the time part of a date-time object as a string formatted with the standard short time format (en-us: hour:minute AM/PM). Be aware that country-specific short time format can hold AM/PM or other formats that does not only hold hour, minute, and seconds.
Supported Runtime Versions
3.0, 4.0, 5.0
Parameters
|
Description |
---|---|
dateTime
|
The date-time object to return the time part for. |
culture
|
The language culture name (e.g. "en" or "en-US") of the culture to convert to as specified by Microsoft. You can use country-specific cultures. |
Return Value
Time part of the date-time object.