OK, well both of those solutions were posted two years ago, more than a year before OH 3 was developed and released.
The examples you need are #3 at the DateTime Conversion (openHAB 3.x) post.
now
is a Java ZonedDateTime. The key is now.toLocalDateTime().toString()
for the first line.
For the second line there is no Joda DateTime any more. See #7 for how to get epoch (i.e. the old now.millis
) and see #2 for how to create a DateTimeType from epoch.