All templates
Date & TimeBeginner
Convert Datetime to Text
Robomotion•Updated 9 months ago

Overview
Converts a datetime value into a formatted text string using the Robomotion DateTime package. Demonstrates standard and custom output layouts for logging, filenames, and reports.
Convert Datetime to Text
Handling datetime data can be challenging, as numerous formats have been adopted across the globe. Robomotion enables the conversion of datetime variables to predefined and custom formats so that flows can handle data independently of the originating region.
What Convert Datetime to Text can do
- Get now (
Robomotion.DateTime.Now,optLayout: RFC3339,optTimezoneOffset: Local) →msg.current_date_time. - Short date (
Robomotion.DateTime.Format, custom out layout1/2/2006) →msg.formatted_date_time; Function buildsmsg.dialog_text = "Current date in 'short date' text format:\n" + msg.formatted_date_time, thenCore.Dialog.MessageBoxtitledResult(info). - Short time (custom out layout
3:04 PM) → dialogCurrent time in 'short time' text format:\n.... - Long date (custom out layout
January 02, 2006) → dialogCurrent date in 'MMMM dd, yyyy' text format:\n.... - Today sentence (custom out layout
Today is 02th day of January of Year 2006) → dialog showingmsg.formatted_date_timedirectly. - 12-hour time (custom out layout
03:04:05 PM) → dialogCurrent time in 'hh:mm:ss tt' text format:\n.... - Time sentence (custom out layout
It is currently 03 hours 04 minutes and 05 seconds.) → dialog showingmsg.formatted_date_timedirectly. - Full datetime (custom out layout
Monday, 02 January, 2006 | 03:04:05 PM) → dialogToday's date and time is ..., thenCore.Flow.Stop.
Behind the scenes
msg.current_date_timeis captured once at the top as RFC3339; every subsequentRobomotion.DateTime.Formatstep reads the same value and only changesoptCustomOutLayout.Robomotion.DateTime.Formatuses Go-style reference-time layouts —1/2/2006,3:04 PM,January 02, 2006, etc. — where the specific reference numbers (year2006, month01, day02, hour15/03, minute04, second05) mark which field goes where. Literal words likeToday isorof Yearpass through verbatim.msg.formatted_date_timeis reused across every format step, so each dialog always reflects the most recent conversion.
More date & time templates
See all 6 →- Convert Text to DatetimeParses a text string like "2025-05-01 09:30:00" into a true datetime value the flow can work with. Shows how to declare an input layout so downstream nodes can format or compare the date.
- Days of Your LifeCalculates how many days you have been alive by subtracting your birthday from today. Uses DateTime Now, Subtract, and a Function node to produce a clean day count.
- Get Current TimeReads the local date and time and formats it as a long time string (HH:mm:ss). Displays the result in an information dialog so you can verify the system clock at a glance.
- Get First Working Day of the Next MonthComputes the first business day of next month, skipping weekends. Useful for scheduling invoices, reports, or reminders that must fire on a working day.
- Get Previous Working DateWalks backwards from today to find the previous working day, handling weekends through conditional logic. A building block for backdated reports or audits.