I know there are a lot of such questions and i tried many of them, but i can't make it work properly, i'm always getting wrong time. I have table with value time, which is set to timestamp. The idea is to use it for forum post with date and time when this post were created, so everyone can see correct time in his own timezone, not servers. This value returns me string like this '2023-01-22 11:42:50', but the time is wrong. How to convert it to local time on client side? And without specifying timezone. I tried this:
const getTime = (str) => {
const d = new Date(str);
return `${d.toLocaleDateString()} ${d.toLocaleTimeString()}`;
}
This returns me '22.01.2023 11:42:50' which is how i wanted but the time is still wrong. Or maybe i should do it on server side? If so, then how to do it in PHP?
UPDATE: I just tried new Date('2023-01-22 11:05:08').toString() from another question and this gives me same time again. I made this post at 18:05 not 11. How to change it?