Closed JdotCarver closed 4 months ago
I need more information.
The code for the time looks correct to me, but either I'm looking in the wrong spot or there is an issue I'm missing.
Is this on the dock.html? Can you please provide details on version, browser, page, url parameters used, etc.
Maybe a screen shot?
Issue is present on 1.77.2 :
This is how it looks like :
This happens on OBS browser source, and what they call "custom browser docks"
Thank you. very strange. I'll do some testing. thank you
Thank you. 🙏
If you need any additional info, feel free to ask.
var clock24hr = false
var date = new Date('2024-06-27T00:40:00Z');
var timeArrived = date.toLocaleString('en-US', { hourCycle: (clock24hr ? 'h23' : 'h12'), hour: "numeric", minute: "numeric" })
console.log(timeArrived)
clock24hr = true
timeArrived = date.toLocaleString('en-US', { hourCycle: (clock24hr ? 'h23' : 'h12'), hour: "numeric", minute: "numeric" })
console.log(timeArrived)
Output:
12:40 AM
00:40
I don't know if it's something correct for your project.
Thank you. I submitted new code already, which is more clearly defined and doesn't rely on toLocaleString
var timeArrived = "";
if (datestamp) {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
minutes = minutes < 10 ? "0" + minutes : minutes;
if (!clock24hr) {
var ampm = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
timeArrived = `${hours}:${minutes} ${ampm}`;
if (compactmode) {
timeArrived = timeArrived.split(" ")[0]; // Removes AM/PM part
}
} else {
hours = hours < 10 ? "0" + hours : hours;
timeArrived = `${hours}:${minutes}`;
}
timeArrived = "<div class='time-arrived'>" + timeArrived + "</div>";
}
I'm probably using it wrong.
var clock24hr = false var date = new Date('2024-06-27T00:40:00Z'); var timeArrived = date.toLocaleString('en-US', { hourCycle: (clock24hr ? 'h23' : 'h12'), hour: "numeric", minute: "numeric" }) console.log(timeArrived) clock24hr = true timeArrived = date.toLocaleString('en-US', { hourCycle: (clock24hr ? 'h23' : 'h12'), hour: "numeric", minute: "numeric" }) console.log(timeArrived)
Output:
12:40 AM 00:40
I don't know if it's something correct for your project.
h11 - 12-hour clock with 0-11, using AM/PM. h12 - 12-hour clock with 1-12, using AM/PM. h23 - 24-hour clock with 0-23. h24 - 24-hour clock with 1-24.
I suppose I was using h24 mode unexpectedly? not sure.
Pretty simple. Activating the 24h option in the extension (shows 24:32 instead of 00:32 for example).