if I get UTC date below 2012-04-17T15:40+05:00 ====result i am expecting======>>> 2012-04-17T15:40+08:00
I don't want to convert I just want to replace the timezone offset
If you're talking about string manipulation, you can do something like this:
function replaceTimezoneOffset(dateTime: string, newOffset: string): string {
return `${dateTime.split('+')[0]}${newOffset}`;
}
And you can use it like this:
const newDate = replaceTimezoneOffset('2012-04-17T15:40+05:00', '+08:00');
console.log({newDate}); // {newDate: '2012-04-17T15:40+08:00'}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.