Datetime input component and Convert it into string

In above image we just enter the date and time using datetime input property ...

... you mean DateTime Input component.

... and also I need the same format of string need to utilize for other function.

Be careful here. You should be using the underlying DateTime data type for all scripting and expressions. Only convert to string at the last moment for display. The "other function" should be using the DateTime data and not the string data. When you do this you are able to use all of Ignition's built-in system.date functions.

But while converting it into other format, am getting different format.

Yes, that is the default return format (by Jython, I think) when you convert to a string. It's a nuisance. The HKT is "Hong Kong Time".

Instead you can use
system.perspective.print(system.date.format(date, "yyyy-MM-dd HH:mm:ss"))
to format it exactly as you want.


Tip: See Wiki - how to post code on this forum.