Sample code for 30+ languages & platforms
Visual FoxPro

Get Certificate Valid To/From Dates

Demonstrates how to get the certificate "valid from" and "valid to" dates.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loCert
LOCAL loCkdt
LOCAL loDt

lnSuccess = 0

loCert = CreateObject('Chilkat.Cert')

lnSuccess = loCert.LoadFromFile("qa_data/certs/testCert.cer")
IF (lnSuccess = 0) THEN
    ? loCert.LastErrorText
    RELEASE loCert
    CANCEL
ENDIF

* Get the certificate valid-from date/time
loCkdt = CreateObject('Chilkat.CkDateTime')
loCkdt.SetFromRfc822(loCert.ValidFromStr)

* Get the local timestamp string.
? "Valid from: " + loCkdt.GetAsTimestamp(1)
* Valid from: 2017-03-17T19:00:00-05:00

* Now get the date/time as another object where we can get the individual numeric date parts.
loDt = CreateObject('Chilkat.DtObj')
loCkdt.ToDtObj(1,loDt)

? STR(loDt.Day) + "/" + STR(loDt.Month) + "/" + STR(loDt.Year) + "  " + STR(loDt.Hour) + ":" + STR(loDt.Minute)

* Get the certificate valid-to date/time
loCkdt.SetFromRfc822(loCert.ValidToStr)

? "Valid to: " + loCkdt.GetAsTimestamp(1)
* Valid to: 2020-03-18T18:59:59-05:00new DtObj dt;
loCkdt.ToDtObj(1,loDt)

? STR(loDt.Day) + "/" + STR(loDt.Month) + "/" + STR(loDt.Year) + "  " + STR(loDt.Hour) + ":" + STR(loDt.Minute)

RELEASE loCert
RELEASE loCkdt
RELEASE loDt