Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.

I'm trying to get birthDate (and other date fields) of the portal user(contact) in liquid in a content snippet, it give me the error "Liquid error: Object of type 'System.DateTime' cannot be converted to type 'System.String'.


var firstname="{{ user.firstname }}";
var lastname="{{ user.lastname }}";
var birthdate="{{ user.birthdate | string }}"; //"{{ user.birthdate }}";


firstname and lastname works fine.

Any help?


Hi @siddiqueMahsud,

If you would like to convert datetime to a specific format check this official doc regarding available datetime filters.

var date = "{{ now | date: 'MMM dd, yyyy' }}";
// output Sep 09, 2021

If you just want to print that value to use as a string you don't need any additional filter and this code will work just fine:

// this will be a string
var birthdate="{{ user.birthdate }}"; 
If you find this post helpful consider marking it as a solution to help others find it.

thank you OOlashyn for your response, seems like there is some issue with my portal, as I'm used the same as you mentioned but not working.

I just simply need the birthdate, no matter what is the format.

My sample code: 






Also, I used like below:


var birthdate="{{ user.birthdate }}"; 


and got below in alert:​





New Member

I'm getting the same issue out of nowhere. Any ideas?

Hi @siddiqueMahsud  & @Eduardo_Garcia 


Can you please try below code:

{% assign birthDate = user.birthdate %}
{{ birthDate }}


If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

Thanks, but it doesn't work. It seems like the latest portal update broke parsing of boolean and datetime for the user object.

Helpful resources

Carousel Community Blog

Check out the Community Blog

Read all about the most recent blogs in the community!

Carousel News & Announcements

What's New in the Community?

Check out the latest News & Events in the community!

Users online (3,551)