|
<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > BuiltIn Functions > Date and Time > cDateTime > cDateTime_Methods > <cDateTime>.InitFrom |
Description
Initialize a cDateTime object to a new date and time.
Syntax
s = <cDateTime>.InitFrom( year [, month [, day [, hour [, minute [, second [, millisecond]]]]]] )
Returns
String in the following <cDateTime>.ToStringFormat("yyyy-MM-dd HH:mm:ss.fff")
Parameters
Name |
Type |
Optional |
Meaning |
year |
Numeric |
No |
Year component of date as number 1601 - 30827. If zero, current year will be used |
month |
Numeric |
Yes |
Month component of date as number 1 - 12. If not specified, 1 is presumed. |
day |
Numeric |
Yes |
Day component of date as number 1 - 31 (in applicable months). If not specified, 1 is presumed. |
hour |
Numeric |
Yes |
|
minute |
Numeric |
Yes |
|
second |
Numeric |
Yes |
|
millisecond |
Numeric |
Yes |
Remarks
Restrictions
Should any of the assigned values be outside of required range, the cDateTime object will remain unchanged.
See also
Examples
' Create an object with current date and time
Dim myDateTime As New cDateTime
' Original form
MsgBox 0, "myDateTime:" + $CRLF + myDateTime.toString
' Modify the DATE to Back to the Future day :)
' TIME will not be altered ;)
myDateTime.NewDate(2015, 10, 21)
' Modified form
MsgBox 0, "myDateTime modified:" + $CRLF + myDateTime.toString