Tip 11: How to extract the time from a Date-Time field.

Tip 11: How to extract the time from a Date-Time field.



Hi folks,

Over the last few months, many of you have been asking for a Time field in Zoho Creator. We realize how important this field is to you all, and we promise to support this as soon as possible. In the meantime, here are a couple of workarounds that will help fetch the time from a Date-Time field.

1. Using the in-built  String functions
The easiest way to extract time for display purpose is to use a toString() function with preferred time format we need. We shall get the 24 hours format or 12 hours format in AM or PM for a given date time value.

24 hours format :
  1. zoho.currenttime.toString("HH:mm:ss"); //Sample Output : 15:30:30

12 hours format :
  1. zoho.currenttime.toString("hh:mm:ss a"); //Sample Output : 03:30:30 PM
Where zoho.currenttime is a system variable which returns the current date with time in the format set in application settings.

Note: Learn more about the syntax and usage of the substring function.

2. Using the in-built  Time and Date functions

Let's say you need to extract the time from the Date-Time field and display it in the following format -- 12Hour 34Minutes 40Seconds. 

For which, you need to create a single line field and name it as 'Time' and then write the below-given code on On Load of the form.

Firstly, you need to fetch the current date and time using the zoho.currentime function and assign it to a variable called 'a'. Later, use the date and time functions to get the hour, minute and second values separately and assign them to three different variables.


  1. a = zoho.currenttime;
  2. b= a.getHour()+"Hour"+" ";  
  3. c=a.getMinutes()+"Minutes"+" ";
  4. d=a.getSeconds()+”Seconds”;
  5. input.time=b+c+d; // Combine all the 3 three variables b,c, and d and assign it to the Time field.

Note: getHour(), getMinutes(), getSeconds() are the default in-built Date and Time functions. You can learn more about them here .

If you have any doubts or queries regarding this tip, please feel free to add them as comments below. We would be happy to address them all.



    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now