CMS Development

VRandima
Mitglied

Get Unixtimestamp of given date time

lösung

I tried the unixtimestamp() hubl function to convert date time to unixtimestamp but it was not successful.

 

I tried like the following.

 

  1. unixtimestamp("2023-09-16 00:00:00")  => no result
  2. unixtimestamp(2023-09-16 00:00:00) => no result
  3. unixtimestamp('2023-09-16 00:00:00') => no result
  4. unixtimestamp(`2023-09-16 00:00:00`) => no result

    Wanted to know how should I pass the date to get the result.
0 Upvotes
1 Akzeptierte Lösung
Jaycee_Lewis
Lösung
Community-Manager/-in
Community-Manager/-in

Get Unixtimestamp of given date time

lösung

Hey, @VRandima 👋 Did you get this worked out? 

 

If not, I have a few questions to help our community better understand your issue.

 

To clarify, the HubL function unixtimestamp() will either render the timestamp of now or you can optionally supply a datetime object you provide. We can see this in the example from the documentation — unixtimestamp, where `(d)` represents the object to be converted:

{{ unixtimestamp(d) }}

 

Typically, you'd use Python or JavaScript to handle creating the datetime object. Here's a simple example I found using Javascript:

let d = new Date("2023-09-16 00:00:00");

 

And the specifics will be dependent on how you are set up and the tools you are using. Otherwise, if you are pasting in raw string or an uninitialized variable, it won't work the way you want it to.

 

Best,

Jaycee


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
3 Antworten
Jaycee_Lewis
Lösung
Community-Manager/-in
Community-Manager/-in

Get Unixtimestamp of given date time

lösung

Hey, @VRandima 👋 Did you get this worked out? 

 

If not, I have a few questions to help our community better understand your issue.

 

To clarify, the HubL function unixtimestamp() will either render the timestamp of now or you can optionally supply a datetime object you provide. We can see this in the example from the documentation — unixtimestamp, where `(d)` represents the object to be converted:

{{ unixtimestamp(d) }}

 

Typically, you'd use Python or JavaScript to handle creating the datetime object. Here's a simple example I found using Javascript:

let d = new Date("2023-09-16 00:00:00");

 

And the specifics will be dependent on how you are set up and the tools you are using. Otherwise, if you are pasting in raw string or an uninitialized variable, it won't work the way you want it to.

 

Best,

Jaycee


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes
VRandima
Mitglied

Get Unixtimestamp of given date time

lösung

Hi @Jaycee_Lewis ,
Thank you for the reply. I thought we could just pass the date time to get unixtimestamp value.

0 Upvotes
Jaycee_Lewis
Community-Manager/-in
Community-Manager/-in

Get Unixtimestamp of given date time

lösung

Hey, @VRandima! Thank YOU for asking this question 🙌

 

It took me a sec to understand “what” the documentation was saying there. I learned something new too. 

 

To me, the docs assume that you'll know what to do with the second option. But they don't give any clues in this case, it's not obvious. I don't think it's meant to be frustrating. But I do think it assumes about knowledge and experience that we'd all have by default. 

 

Have fun building! — Jaycee 


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes