I had a client try to book on to one of my course but kept insisting that the date he was looking for wasn’t listed, after some emails back and forth and nearly loosing the client, I sent a screen shot which seemed to puzzle him, the dates showing for me and what’s in my database was on my screen (UK) but on his screen (US) it was showing one date behind, he changed his time zone and it solved the display issue. This obviously needs fixing but it only recently become highlighted and I have never had a problem before, not sure if it’s anything to do with wix turbo??
I have been doing some research and had some help from the Facebook pages but still seem to be struggling with this. I have adjusted my code after reading an article on Date.toLocaleDateString() and some variations, which all adjust the format for the users timezone but it doesn’t retain the date which is in my database. I could really do with a little help with this one as all of my start dates are one day out if not viewed in the UK!
That is because .toLocaleDateString uses the default local data on the device.
Try this code to check the output:
// America/Los_Angeles for the US
// US English uses month-day-year order
date.toLocaleDateString('en-US');
//or
date.toLocaleDateString('en-US', options)
// → "12/19/2012"
// British English uses day-month-year order
date.toLocaleDateString('en-GB');
//or
date.toLocaleDateString('en-GB', options)
// → "20/12/2012"
Have a look at these pages if you haven’t done already:
Hey @givemeawhisky , thanks for the info. I’ve had a look at the documents a few days ago and played with the code, to mu knowledge the code adjusts (as you mentioned in your code above) the format of the date, but the issue I’m having is that the date is changing to the time zone. The pictures below are form the same trip, but I have changed the time zone on my computer.
@yisrael-wix@yoav-wix can you guys shed any light on this one? I have a sinking feeling this has been this way since I started the website when Wix code was first introduced. I basically only want the date that’s in my database (UK) to show regardless of the users timezone. From research I know that in java dates will be adjusted to the timezone of the user, but how to I stop this happening?
I have noticed that when i change the timezone on my computer it also adjusts the dates in the database…
Thank you in advance
It may be because the server time/date is being used as opposed to the local (browser) time/date. Also, sometimes it depends on how you retrieve that date and time from the Date() object.
See the Open for Business example - it seems to show the correct date and time.
Hi Stephen,
Thank you for raising this issue. I’m also experiencing the same issue. The date in the collection is shown 1 day before when using " toLocaleDateString(‘en-UK’, options)" for displaying to the user. Can you please mail me the solution code to avn.solsys@gmail.com
I’m scrambling a lot and seems like my head will blast.
Hi @avshrss , I was able to get in touch with Stephen and actually hired him to make the fix for me. I don’t know if he’s available for new gigs or not, but I HIGHLY recommend him. He was awesome!
Hello everyone, has this been solved? I’m facing the same issue and its causing a lot of confusion in my databases. OP said he paid someone to fix this. It was somebody on Wix? An external developer?