Store date and time when a OPC tag value come to a tag

Hello guys,
Hope you are doing well.
I am facing issues with a script that is working in 7.9.17 properly but not working in 8.1.7.
This script is to store realtime date and time once a alarm generate, alarm is in a OPC tag.
Used a timer for this functionality and written script on it.

can anyone suggect me solution.

used a table to store date and time in TimeStamp colomn.

Tip: paste code, not pictures of code. Use the </> code formatting button to preserve code indentation and apply syntax highlighting. That way we can copy and paste the code into our answers.

if UDT_tag==event.source.parent.tagPath:
			#print UDT_tag
			TimeStamp = temp['TimeStamp']
			TimeStampilliseconds = int(time.mktime(time.strptime(TimeStamp,'%y-%m-%d %H:%M:%S'))*1000)*60
			TimeStampDate =,int(OffsetMinutes))
			TimeStamp=,'yyyy-MM-dd HH:mm:ss')