How to get the Device Date and Time using react native?

I want to get the device time and date to find the difference between the days. I used the code date1 = new Date().getTime() this returns the server time not the device time. Any solutions?

1 answer

  • answered 2018-07-12 07:43 Kishan Gujarati

    To get date and time use these code

    for date

    const day = new Date().getDate(); const month = new Date().getMonth() + 1; const year = new Date().getFullYear();

    for time

    const sec = new Date().getSeconds(); const min = new Date().getMinutes(); const hour = new Date().getHours();