@@ -22,8 +22,8 @@ export const MonetizeSubscriptionTerms = ( {
2222 return < > { __ ( 'Never expires' ) } </ > ;
2323 }
2424
25- // Check if end_date is in the past
26- const endDate = new Date ( subscription . end_date ) ;
25+ // Check if end_date is in the past (convert to ISO 8601 and append Z to parse as UTC)
26+ const endDate = new Date ( subscription . end_date . replace ( ' ' , 'T' ) + 'Z' ) ;
2727 const isExpired = endDate < new Date ( ) ;
2828
2929 // Show "Expired" for past dates
@@ -44,14 +44,14 @@ export const MonetizeSubscriptionTerms = ( {
4444 { subscription . renew_interval === null
4545 ? // translators: %(date)s is the date the subscription expires. Format is LL (e.g. January 1, 2020).
4646 sprintf ( __ ( 'Expires on %(date)s' ) , {
47- date : formatDate ( new Date ( Date . parse ( subscription ? .end_date ?? '' ) ) , locale , {
47+ date : formatDate ( new Date ( subscription . end_date . replace ( ' ' , 'T' ) + 'Z' ) , locale , {
4848 dateStyle : 'long' ,
4949 } ) ,
5050 } )
5151 : // translators: %(amount)s is the renewal price, %(date)s is the date the subscription renews. Format is LL (e.g. January 1, 2020).
5252 sprintf ( __ ( 'Renews at %(amount)s on %(date)s' ) , {
5353 amount : formatCurrency ( Number ( subscription . renewal_price ) , subscription . currency ) ,
54- date : formatDate ( new Date ( Date . parse ( subscription ? .end_date ?? '' ) ) , locale , {
54+ date : formatDate ( new Date ( subscription . end_date . replace ( ' ' , 'T' ) + 'Z' ) , locale , {
5555 dateStyle : 'long' ,
5656 } ) ,
5757 } ) }
0 commit comments