Search code examples
firebasefirebase-realtime-databasefirebase-security

How can I extend the firebase test mode read/write rules beyond 30 days?


I'm working on a small project that isn't too serious so I'm not going to implement any real rules to its realtime database, but I'll need a bit more than 30 days for the test mode to be running.

My question is, what's the date format on these rules used below by Firebase?

{
  "rules": {
".read": "now < 1638392400000",  // 2021-12-2
".write": "now < 1638392400000",  // 2021-12-2
  }
}

Solution

  • The 1638392400000 value is just an Unix epoch timestamp in milliseconds.

    The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).


    You can use an online converter like https://www.epochconverter.com/ to generate a new Timestamp value and adapt your rules with this value.

    For example, 2021-12-2 will give a Timestamp of 1638403200000 and therefore your rules should be changed to:

    {
      "rules": {
        ".read": "now < 1638403200000", 
        ".write": "now < 1638403200000",  
      }
    }