# DateTime field on Hubl

**URL:** <https://community.hubspot.com/t/datetime-field-on-hubl/130929>\
**Category:** CMS Development\
**Created:** [May 1, 2025, 4:24pm UTC](https://community.hubspot.com/t/datetime-field-on-hubl/130929 "2025-05-01T16:24:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MLManifest](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MLManifest](https://community.hubspot.com/u/MLManifest)\
**Post date:** [May 1, 2025, 4:24pm UTC](https://community.hubspot.com/t/datetime-field-on-hubl/130929/1 "2025-05-01T16:24:21Z")

</div>

Only the date value is returned when fetching the datetime field in Hubl.

If you run the `crm_object` function to get a CRM object instance that has a datetime field (DateTime Picker), it will only return the date instead of the date time.

```lia-code-sample
{% set course= crm_object("COURSE", selectedCourseId, "start_date_time") %}
{{ shortCourse|tojson }}

// You would get instead of a timestamp or in a format with both date and time
{"start_date_time":"07/04/25"}

```

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [May 2, 2025, 6:49am UTC](https://community.hubspot.com/t/datetime-field-on-hubl/130929/2 "2025-05-02T06:49:23Z")

</div>

Hi @MLManifest and welcome, we are so glad to have you here!  
Thanks for asking the HubSpot Community!  
For information, here is the “[HubL syntax overview](https://developers.hubspot.com/docs/reference/cms/hubl/overview)”.  
I’d love to invite our Top Experts to join this conversation: Hi @Anton, @Kevin-C and @Stephanie-OG when you are using HubL, do you also get the same result as @MLManifest? Do you have a workaround to have the date time to help @MLManifest, please?  
Have a wonderful day and thanks so much! ❤  
Bérangère

---

<div class="post-metadata">

**Author:** ![kosalaindrasiri](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kosalaindrasiri/32/44349_2.png) [@kosalaindrasiri](https://community.hubspot.com/u/kosalaindrasiri)\
**Post date:** [May 2, 2025, 7:32am UTC](https://community.hubspot.com/t/datetime-field-on-hubl/130929/3 "2025-05-02T07:32:29Z")

</div>

Hey @MLManifest,

​When retrieving a datetime field using HubL’s crm\_object function, it’s common to encounter a display that shows only the date portion, omitting the time. This behavior occurs because HubSpot’s templating engine, by default, formats datetime values to display only the date unless explicitly instructed otherwise.

To display both the date and time components, you can utilize the format\_datetime filter in your HubL code.

```lia-code-sample
{% set course = crm_object("COURSE", selectedCourseId, "start_date_time") %}
{{ format_datetime(course.start_date_time, "%B %e, %Y %I:%M %p", local_time_zone) }}

```

In this example:

- “%B %e, %Y %I:%M %p” formats the datetime to display the **full month name, day of the month, year, and time in 12-hour format with AM/PM.**
- local\_time\_zone ensures that the datetime is displayed in your account’s configured timezone. If you omit this parameter, the time will default to Coordinated Universal Time (UTC).

The format\_datetime filter is the recommended approach, as the previously used datetimeformat filter has been deprecated.

Here is a previous community thread I found about date formatting - [https://community.hubspot.com/t5/CMS-Development/HubDB-date-formatting/m-p/478944/highlight/true#M24494](https://community.hubspot.com/t5/CMS-Development/HubDB-date-formatting/m-p/478944/highlight/true#M24494)

Additional Resources: [HubL Syntax - HubSpot docs](https://developers.hubspot.com/docs/reference/cms/hubl/overview#filters-and-functions)

Regards,

Kosala

---

<div class="post-metadata">

**Author:** ![MLManifest](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MLManifest](https://community.hubspot.com/u/MLManifest)\
**Post date:** [May 2, 2025, 9:04am UTC](https://community.hubspot.com/t/datetime-field-on-hubl/130929/4 "2025-05-02T09:04:03Z")

</div>

Thanks Kosala,

Unfortunately, that doesn’t work as the crm\_objects function currently returns a plain string date. Below is the screenshot of the test I ran.

![datetime.png](https://d2qpr2jzcazej7.cloudfront.net/optimized/3X/7/3/73a778af0ad64de3884cc40195af5eadb59c7cf6_2_690x42.png)

---

<div class="post-metadata">

**Author:** ![MLManifest](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@MLManifest](https://community.hubspot.com/u/MLManifest)\
**Post date:** [May 2, 2025, 12:27pm UTC](https://community.hubspot.com/t/datetime-field-on-hubl/130929/5 "2025-05-02T12:27:48Z")

</div>

Okay, it seems the datetime is formatted to give only a date string when we run the `crm_object` function by default. We need to pass the argument for formatting (pass `false` ) to get the plain timestamp value.

`{% set course= crm_object("COURSE", selectedCourseId, "start_date_time", false) %}`

---

<div class="post-metadata">

**Author:** ![kosalaindrasiri](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kosalaindrasiri/32/44349_2.png) [@kosalaindrasiri](https://community.hubspot.com/u/kosalaindrasiri)\
**Post date:** [May 2, 2025, 12:35pm UTC](https://community.hubspot.com/t/datetime-field-on-hubl/130929/6 "2025-05-02T12:35:07Z")

</div>

@MLManifest ​You’re correct in noting that the crm\_object function in HubL returns formatted date strings by default. To retrieve the raw timestamp value, you can pass false as the fourth argument.  
[https://community.hubspot.com/t5/CMS-Development/HubL-displaying-different-date-values/td-p/970140](https://community.hubspot.com/t5/CMS-Development/HubL-displaying-different-date-values/td-p/970140)  
Thanks!
