'How to get time and date not from the phone

In android studio kotlin or firebase how do I get the utc time and date that will be same on everyone's phone.

This is the code for getting utc time:

fun getUtcTimeAndDate(): String {
    val df = SimpleDateFormat("MMM dd, h:mm a")

    df.timeZone = TimeZone.getTimeZone("UTC")
    return df.format(Date())
}

It gets the utc time from your phone but some phones have slightly different utc times.

I want to get the utc time from somewhere that on everyone's phone will be the same.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source