![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Parse a Microsoft JSON Date (MS AJAX Date)Demonstrates how to parse a Microsoft JSON Date, also known as an MSAJAX date. Note: This example requires Chilkat v11.0.0 or greater.
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoJson Variant vDt Handle hoDt Boolean iBLocal Variant vDtObj Handle hoDtObj String sTemp1 Integer iTemp1 Move False To iSuccess // Parse Microsoft JSON Dates (AJAX Dates) Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComLoad Of hoJson '{ "AchievementDate":"/Date(1540229468330-0500)/"}' To iSuccess Get Create (RefClass(cComCkDateTime)) To hoDt If (Not(IsComObjectCreated(hoDt))) Begin Send CreateComObject of hoDt End Get pvComObject of hoDt to vDt Get ComDateOf Of hoJson "AchievementDate" vDt To iSuccess If (iSuccess <> True) Begin Showln "Unable to parse a date/time." Procedure_Return End // Show the date in different formats: Move True To iBLocal Get ComGetAsRfc822 Of hoDt iBLocal To sTemp1 Showln "RFC822: " sTemp1 Get ComGetAsTimestamp Of hoDt iBLocal To sTemp1 Showln "Timestamp: " sTemp1 Get ComGetAsIso8601 Of hoDt "YYYY-MM-DD" iBLocal To sTemp1 Showln "YYYY-MM-DD: " sTemp1 // Get integer values for year, month, day, etc. Get Create (RefClass(cComChilkatDtObj)) To hoDtObj If (Not(IsComObjectCreated(hoDtObj))) Begin Send CreateComObject of hoDtObj End Get pvComObject of hoDtObj to vDtObj Send ComToDtObj To hoDt iBLocal vDtObj Get ComYear Of hoDtObj To iTemp1 Showln "year: " iTemp1 Get ComMonth Of hoDtObj To iTemp1 Showln "month: " iTemp1 Get ComDay Of hoDtObj To iTemp1 Showln "day: " iTemp1 Get ComHour Of hoDtObj To iTemp1 Showln "hour: " iTemp1 Get ComMinute Of hoDtObj To iTemp1 Showln "minute: " iTemp1 Get ComSecond Of hoDtObj To iTemp1 Showln "seconds: " iTemp1 // Sample output: // RFC822: Mon, 22 Oct 2018 17:31:08 -0500 // Timestamp: 2018-10-22T17:31:08-05:00 // YYYY-MM-DD: 2018-10-22 // year: 2018 // month: 10 // day: 22 // hour: 17 // minute: 31 // seconds: 8 End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.