title: How do you make a real time database query that checks if timestamp of users are in today?
body: <p>So, say each user in a RTDB has a child called caption. This child is a timestamp of seconds since 1970. Now you want to display all users who have a timestamp that is in today. You need to query the database for all users with a timestamp that is in today, because you don't want to send all users to the phone and then filter.</p>
  <p>Below, in the first code is how I am currently sending all users to the device and then filtering. The second set of code is where I am attempting to first query all users who have a timestamp in today, ie before sending all to the users device.</p>
  <p>One idea would be to make a firebase entry automatically each day that just represents the day. Then just compare that to all the timestamps of the users. The issue I have with that is that timezones are different.</p>
  <pre><code>var dict = CLLocation()
           ...
  dict = CLLocation(latitude: lat, longitude: lon)
          ...
  let thisUsersUid = Auth.auth().currentUser?.uid
  self.refArtists2 = Database.database().reference().child(&quot;people&quot;);                                            self.refArtists2.observe(DataEventType.value,  with: {  snapshot in
  if snapshot.childrenCount&gt;0{
     self.people.removeAll()
              for people in snapshot.children.allObjects as! [DataSnapshot] {
                  if people.key != thisUsersUid {
                  let peopleObject = people.value as? [String: AnyObject]
                  let peoplecaption = peopleObject?[&quot;caption&quot;] as? Int //is timestamp
                  let coordSnap12 = people.childSnapshot(forPath: &quot;caption&quot;).value as? Int ?? 0
                  let date = Date(timeIntervalSince1970: TimeInterval(coordSnap12)/1000.0)
                  //let secondsInDay = 86400
                  **if Calendar.current.isDateInToday(date)** {
  </code></pre>
  <p>.</p>
  <pre><code> var ppp: String!  ////this should be the uid of all users in db
  
      let people = Database.database().reference().child(&quot;people&quot;).child(self.ppp).child(&quot;captions&quot;)
  people.observe(DataEventType.value, with: {  snapshot in
      let captionss = snapshot.value as? Int ?? 0
      let date = Date(timeIntervalSince1970: TimeInterval(captionss)/1000.0)       
      let query1 = Database.database().reference().child(&quot;people&quot;).queryOrdered(byChild: &quot;caption&quot;).where?(isDateInToday(date))
  </code></pre>