如何在 React Js 中将时间字符串转换为印度标准时间?

How to convert time string to indian standard time in React Js?

我正在尝试从唯一的时间字符串中获取当地时间。我收到的 api 响应只有 12:30 PM 之类的时间字符串,我已经像下面这样尝试过,但是当时间为 00:00 时它不起作用(我收到 5:30 am ), 但它在其他时间工作,我也尝试过使用时刻时区,但每当我的时间是 00:00 我得到 05:30 AM

{moment.utc(user.checkin_time, 'hh:mm A').local().format('hh:mm A')}

终于在@pilchard 的帮助下我找到了答案

moment.utc(user.checkin_time, 'hh:mm A').tz('Asia/Kolkata').format('hh:mm A')