Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cmiqueo
Copy link
Collaborator

@cmiqueo cmiqueo commented Mar 11, 2025

Description:
Sanitizes createdDate format when the timestamp is set to 00:00:00.0000Z

Simple and effective implementation that when the timestamp is set to 00:00:00.0000Z removes the 'Z' part of the string before creating the JavaScript object and using the local timezone instead of 'GMT'

Test page:
Content as a Service v3 - Tuesday, March 11, 2025 at 10:15

@github-actions
Copy link

Core Web Vitals Metrics

Metric Value
LCP 13650.40 s
FID 0.90 ms
CLS N/A

Recorded at: 2025-03-11T13:10:14.846Z
PR: #258

@github-actions
Copy link

Core Web Vitals Metrics

Metric Value
LCP 15682.00 s
FID 0.80 ms
CLS N/A

Recorded at: 2025-03-11T17:22:43.108Z
PR: #258

@github-actions
Copy link

Core Web Vitals Metrics

Metric Value
LCP 13998.20 s
FID 0.90 ms
CLS N/A

Recorded at: 2025-03-11T21:38:00.555Z
PR: #258

const localCreatedDate = new Date(cardDate);
detailText = localCreatedDate.toLocaleDateString();
} else if (detailsTextOption === 'staticDate' && cardDate) {
const staticDate = new Date(cardDate.replace(/Z$/, ''));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very clean solution!

Much better than just splitting by T and taking the left hand (as it'll also localize the dates in the right format)

@github-actions
Copy link

Core Web Vitals Metrics

Metric Value
LCP 10613.70 s
FID 0.80 ms
CLS N/A

Recorded at: 2025-03-12T22:58:12.997Z
PR: #258

@cmiqueo cmiqueo merged commit 3de1303 into main Mar 14, 2025
13 checks passed
@cmiqueo cmiqueo deleted the MWPW-169194 branch December 1, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants