Sample code for 30+ languages & platforms
Lianja Requires Chilkat v11.0.0+

Get Certificate Valid To/From Dates

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

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loCert = createobject("CkCert")

llSuccess = loCert.LoadFromFile("qa_data/certs/testCert.cer")
if (llSuccess = .F.) then
    ? loCert.LastErrorText
    release loCert
    return
endif

//  Get the certificate valid-from date/time
loCkdt = createobject("CkDateTime")
loCkdt.SetFromRfc822(loCert.ValidFromStr)

//  Get the local timestamp string.
? "Valid from: " + loCkdt.GetAsTimestamp(.T.)
//  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("CkDtObj")
loCkdt.ToDtObj(.T.,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(.T.)
//  Valid to: 2020-03-18T18:59:59-05:00new DtObj dt;
loCkdt.ToDtObj(.T.,loDt)

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


release loCert
release loCkdt
release loDt