skip to Main Content

I am have an idea on how I could get the time but its always in 24 hour format, how can I get it into being in a 12 hour format??

any suggestions??

2

Answers


  1. You can use any js date-time library you prefer. For example https://date-fns.org/v2.29.3/docs/format
    Regarding getting the proper timezone, first, you need to get your device’s timezone with

    import DeviceInfo from 'react-native-device-info';
    
    DeviceInfo.getTimezone();
    

    and then use this timezone with date-time library https://date-fns.org/v2.29.3/docs/Time-Zones

    Login or Signup to reply.
  2. use Moment format to do that

    moment().format("hh:mm a")
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search