'ZPL - how to insert dateTime string in QR code?

I have ZPL like this, it prints a QR code

^XA

^FO50,100
^BQN,2,5,Q
^FD
Hello world!
Some data
Printed on: dateTimeString
^FS

^XZ

What to put in place of dateTimeString so that the following appears when the QR is scanned

Hello world!
Some data
Printed on: 29-Apr-2022 15:35:54

The printer is Zebra ZD421, if that matters. Thanks



Solution 1:[1]

Assuming the RTC is correctly set on the printer, have you tried to use the date\time wildcard available in ZPL? Just tested the following code and it did the job

^XA
^FO50,100
^BQN,2,5,Q
^FH\^FC%,{,#
^FDLA,Hello world!\0D\0ASome data %d-%b-%Y %H:%M:%S^FS
^PQ1,0,1,Y
^XZ

check here for additional info

Solution 2:[2]

The code would have to be in the scanning device/program, not on the printing device.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 WeeMan
Solution 2 EdHayes3