A little help modifying from template

Hi
Just starting out with SmartThings and playing around with handlers.
I have the BASICS of writing/reading code from some C++ courses in first year, but not much past that.

I’m looking to add the functionality described here (display when the sensor was last opened):
https://community.smartthings.com/t/door-sensor-display-when-last-opened/76575

First attempt was to take the template of the Z-Wave Door/Window sensor, and add the code bits that used “lastcheckin”. No dice, but not sure where I’ve gone wrong (I did have to figure out I need to change the “runlocally” to false.

If you want, take a look at this DTH for the Xiaomi door sensor - it has functionality for a “lastOpened” and “lastOpenedDate” as a secondary control. Note that it also allows you to reset manually and has a date format.

Note that it has a date format (US vs. UK) in preferences which feeds into the functionality to get current time.