From c7b6691fa690e550bc36aa7365559b0683c4da7a Mon Sep 17 00:00:00 2001 From: dkmyta <43220201+dkmyta@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:12:19 -0700 Subject: [PATCH] Protect: Fix last_checked conversions (#39549) * Convert last_checked value so it in local time before the WP install timezone conversions apply * changelog * Update var naming --- .../protect/changelog/fix-protect-last-checked-conversions | 4 ++++ projects/plugins/protect/src/js/components/summary/index.jsx | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/protect/changelog/fix-protect-last-checked-conversions diff --git a/projects/plugins/protect/changelog/fix-protect-last-checked-conversions b/projects/plugins/protect/changelog/fix-protect-last-checked-conversions new file mode 100644 index 0000000000000..e2a903b5304db --- /dev/null +++ b/projects/plugins/protect/changelog/fix-protect-last-checked-conversions @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Fixes lastChecked conversions diff --git a/projects/plugins/protect/src/js/components/summary/index.jsx b/projects/plugins/protect/src/js/components/summary/index.jsx index 618f4b78213ad..3cfa665084fc4 100644 --- a/projects/plugins/protect/src/js/components/summary/index.jsx +++ b/projects/plugins/protect/src/js/components/summary/index.jsx @@ -17,6 +17,9 @@ const Summary = () => { } = useProtectData(); const { hasPlan } = usePlan(); + // Convert the last checked UTC date to a local timestamp + const lastCheckedLocalTimestamp = new Date( lastChecked + ' UTC' ).getTime(); + // Popover anchors const [ dailyScansPopoverAnchor, setDailyScansPopoverAnchor ] = useState( null ); @@ -38,7 +41,7 @@ const Summary = () => { { sprintf( /* translators: %s: Latest check date */ __( 'Latest results as of %s', 'jetpack-protect' ), - dateI18n( 'F jS', lastChecked ) + dateI18n( 'F jS', lastCheckedLocalTimestamp ) ) } { ! hasPlan && (