Custom Date field is showing incorrect Date

Hello team,

Weird one today, I have created a Date field labeled “Last Surveyed Date”. image

I have built an app that fills in this date with today’s date but it shows up as yesterday’s date. I am sure this is an easy fix but I can’t seem to figure it out.

Here is the code snippet for this portion.

It seems like it should set the correct date, as I have a console.log that prints out “todaysDate” and it shows correct in the console. image

Any thoughts?

thanks,
Zach

Hey @Zach, could you experiment with the values (like try setting yesterday’s date/ tomorrow’s date) and post the results here? Might be we are missing some behaviour here which got added to the custom field.

I’m sorry @prithvi I am not following. Are you saying you need me to create a new Date object that contains yesterday’s date or tomorrow’s date and then set that as what is sent in the PUT request?

Do you think it has anything to do with the fact that the custom field is a “Date Picker” field and not a text field?

Sorry for the confusion. I’m sure what you are asking me to do is something simple lol.

Yes this please. And do post the results here after this.

@prithvi, my other thought is that it has to do with timezone conversion. I bet the date is being created under UTC and then converted to EST (the timezone of our freshservice instance) which is 4 hours behind UTC therefore making it the day before. hmmm…I bet this is the problem

2 Likes

Well I was right it was the date and time zone clash. Easy fix was to just set the date object for the current date plus 1 then let the timezone correction bring it back 4 hours to the correct date. Weird workaround but its working. Thank you for the help.

3 Likes

Hey @Zach

Quick suggestion. Did you happen to take a look at this -> Datepicker (fw-datepicker) | Crayons

Hello @shravan.balasubraman, really appreciate your feedback but I’m not sure it applies here. The custom field is not built by my application. It’s a custom field added to the freshservice Requester profile therefore the data/field type is maintained by freshworks source code. I do like your idea of sticking to utilizing Crayons for page elements on frontend applications as it unifies the user experience. :+1:

Thanks for your help.