(PowerBuilder) Get Current Date/Time as Timestamp (YYYY-MM-DDThh:mm:ssTZD)
Demonstrates how to get the current system date/time in YYYY-MM-DDThh:mm:ssTZD format.
integer li_rc
oleobject loo_Dt
integer li_Success
integer li_BLocal
string ls_Timestamp
loo_Dt = create oleobject
// Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0
li_rc = loo_Dt.ConnectToNewObject("Chilkat.CkDateTime")
if li_rc < 0 then
destroy loo_Dt
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Dt.SetFromCurrentSystemTime()
// Get a UTC time.
li_BLocal = 0
ls_Timestamp = loo_Dt.GetAsTimestamp(li_BLocal)
Write-Debug "Current UTC Time: " + ls_Timestamp
// Get a local time.
li_BLocal = 1
ls_Timestamp = loo_Dt.GetAsTimestamp(li_BLocal)
Write-Debug "Current Local Time: " + ls_Timestamp
// Sample output:
//
// Current UTC Time: 2022-03-01T00:48:58Z
// Current Local Time: 2022-02-28T18:48:58-06:00
destroy loo_Dt
|