0

my portal consists of multiple country and the data retrieved from the datalake is in UTC timezone. So whenever the user try to navigate in one of page in the portal of the specific country. The portal will display based on the specific page country timezone

Im trying to send a date object variable to one of my endpoints. And from the angular Date object, it will follow the user of the portal timezone.

What im trying to achieve is something similar to momentJS code snippet below:

moment(this.routeParams.startTime).utc(true).startOf('day').format()

where it will return format like this: 2023-09-11T00:00:00Z

but since we are using angular date object, it will return something like : Fri, 29 Sep 2023 01:52:02 GMT

where i want dont want the GMT and i want the time HH:MM:SS to be correct or wanting that Z at the end of the momentjs query

Do anyone have any ideas how do i get the desired output

1 Answer 1

1

Looks like you are using the Angular long format type https://angular.io/api/common/DatePipe#pre-defined-format-options Have you tried picking any options that might suit your use case? Angular built in date pipe also provide custom date time format https://angular.io/api/common/DatePipe#pre-defined-format-options

it should be something like

{{ startTime | date: 'short' }}

in ng template or

new DatePipe().transform(startTime)

in js/ts code

1
  • Yep i did, but i believe DatePipe will return string object instead of date object. What im trying to achieve is that like using moment with toDate() method like moment(this.routeParams.startTime).utc(true).startOf('day').format().toDate(). But since its angular convert to date, it will use the user date and timezone. Commented Sep 29, 2023 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.