# Datetime input component and Convert it into string

**URL:** <https://forum.inductiveautomation.com/t/datetime-input-component-and-convert-it-into-string/83774>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 4, 2024, 3:15am UTC](https://forum.inductiveautomation.com/t/datetime-input-component-and-convert-it-into-string/83774 "2024-01-04T03:15:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 4, 2024, 5:57am UTC](https://forum.inductiveautomation.com/t/datetime-input-component-and-convert-it-into-string/83774/2 "2024-01-04T05:57:27Z")

</div>

> 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](https://docs.inductiveautomation.com/display/DOC81/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](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

_[View the full topic](https://forum.inductiveautomation.com/t/datetime-input-component-and-convert-it-into-string/83774)._
