Displayed 'last updated date' and time glitched!

Hi !

I’m having an issue with the displayed ‘last updated time and date’ on my website, it worked fine until now, but now for some reasons the time and date are wrong, even though they are correct in the database.

For instance, I have an item that was last updated at 9:58, it shows that time in the database, but the time shown on the website is 7:58.

Any help please ?

Thanks !

Hey Tristan,

Sounds like you’ve got an issue with UTC vs. local time zone issues. Not sure why it happened all of a sudden, but seems like you need to worry about time zones. You can do a search on the Javascript Date() object and all of the fun stuff associated with time zone and UTC issues.

Have fun :upside_down_face:,

Yisrael

What do you mean ? Is it going to be fixed soon ? Or should I do something to fix it ?

Nothing’s broken. You’ll need to take care of time zones in order to properly display the correct times. A search on the subject should provide you with the info needed.

Hi,

So I made some research but couldn’t find any way to fix this :confused:

Have you tried the advice in the article How to Display Today’s Date on Your Site ? Is the time that is in the database the actual time that the site was viewed (locally), or is it the UTC-0 time?

I’d like to take a look at this. Please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor. Of course, the problem might be that it will work in my time zone, but perhaps doesn’t work in yours.

Here is my website :

The thing is I already have some code that optimizes the format, so I don’t really know how to apply that LocalDate bit of code.

Opened up the site but I have no idea what I’m looking for. Please explain to me where I will see the discrepancies in the times. Thanks

There are two dates elements in 2 repeaters on the home page. Each has its own bit of code to set the date in a custom format :

//modifies the time and date
  			// Get the orginal date (any format)
			let originalDate = itemData._updatedDate; 
  		
  			// Convert the original date into a Date object
  			let newDate = new Date(originalDate);
  		
  			// Output updated date format
			$w("#text68").text = 
			'Dernière mise à jour le '
			// Get the day
			+ newDate.getUTCDate() + ' '
			// Get the month
			+ monthName[newDate.getUTCMonth()] + ' '
			// Get the year
			+ newDate.getUTCFullYear() + ' à '
			// Get the hour
			+ newDate.getUTCHours() + ':'
			// Get the minute
			+ (newDate.getUTCMinutes()<10?'0':'') + newDate.getUTCMinutes() + ':'
			// Get the second
			+ (newDate.getUTCSeconds()<10?'0':'') + newDate.getUTCSeconds();

You are using the UTC variant of the Date functions which is the cause of the difference. Refer to Date and time for details.

I don’t understand anything :frowning:

Isn’t there a simple line to change in the code ?

I believe that all you need to do is to get rid of the UTC and use standard Date functions.

It seems to work, awesome, many thanks !

Yay! Now I can have my beer. :upside_down_face:

Sure, if you come to France !