Skip to content

Timestamp (Current Date & Time)

In this article, we will explore the use of Timestamp data in PandaSuite. Timestamp is an important concept for knowing the current date and time and using it in your applications.

Timestamp Illustration

Timestamp

Add this template to your account in just a few clicks. Edit and customize it freely.

→ Add this template to your account

Timestamp data

The Timestamp represents the number of seconds that have elapsed since January 1, 1970, at precisely midnight UTC. It is used as a reference for measuring and representing date and time. In PandaSuite, this variable is accessible from the Project data. This allows you to obtain the current date and time in your applications, based on the device’s time.

For example, the Timestamp data corresponding to June 6, 2021, at 1:30 AM and 0 seconds is: 1622943024.

Example Timestamp

Displaying time in an application

To display the time in an application, follow these steps:

  1. Insert a text block into your screen.
  2. Add a data binding to the Content property.
  3. Choose Project > Context > Timestamp as the data source.
  4. Use the Format Date function to set the time display format.
  5. Select the desired formatting settings.

By using this approach, you can display the current time in your PandaSuite application according to the specified format.

Displaying date in an application

To display the date in an application, follow these steps:

  1. Insert a text block into your screen.
  2. Add a data binding to the Content property.
  3. Choose Project > Context > Timestamp as the data source.
  4. Use the Format Date function to set the date display format.
  5. Select the desired formatting settings.

By using this approach, you can display the current date in your PandaSuite application according to the specified format.

Creating a condition based on date/time

It is often necessary to create conditions based on the current time in an application. For example, you may want to display a different message depending on the time of day. To achieve this in PandaSuite, you can use conditional actions based on the Timestamp data.

To display a message based on the time, follow these steps:

  • Prepare all the messages in a Multi-state component.
  • Add a condition that uses Project > Context > Timestamp as the data source.
  • Use the Format Date function to customize the format and the H code to return the hour as a number from 0 to 23 when using a 24-hour clock.
  • Use the Parse Number function to parse the string with a number and return the number.
  • Finalize the condition by adding a lower and upper value.
  • Add the action: Interact with a component > Multi-state > Change state.
  • Repeat the same steps for the other messages.

Formatting the Timestamp data with the Format Date function

To format the Timestamp data according to a desired format, you can use the Format Date function in PandaSuite. This function allows you to customize the appearance of the date and time by using specific parameters.

Formatting Example

Note: When editing in PandaSuite Studio, these data will be displayed based on the current language of the project. If you want to enforce a language, add a default language.