# How should the photon sync the time with the cloud

**URL:** <https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080>\
**Category:** Libraries\
**Created:** [August 3, 2015, 6:57pm UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080 "2015-08-03T18:57:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![helxsz](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@helxsz](https://community.particle.io/u/helxsz)\
**Post date:** [August 3, 2015, 6:57pm UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/1 "2015-08-03T18:57:05Z")

</div>

Right now, I want to the spark photon to execute a task at some certain time, but first of all the spark photon needs to sync with cloud to know what is the current time in this timezone, how would I do it ?

---

<div class="post-metadata">

**Author:** ![lami](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/lami/32/3576_2.png) [@lami](https://community.particle.io/u/lami)\
**Post date:** [August 3, 2015, 7:56pm UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/2 "2015-08-03T19:56:48Z")

</div>

Photon synchronizes its internal RTC on the startup, when connecting to cloud. It takes a while, so you may want to wait for it. There is nice thread discussing how to do it. But you have to set the timezone by yourself, if I am not mistaken.

> [@Time Synchronization: Can't Set RTC Time Upon Reboot \[SOLVED\]](https://community.particle.io/t/time-synchronization-cant-set-rtc-time-upon-reboot-solved/8803):
>
> Hello there, So I’m using the Spark.syncTime(); function in my void setup() and I’m running into an issue that I can’t seem to work around. void setup() { Spark.connect(); Spark.syncTime(); Spark.process(); Spark.disconnect(); Time.zone(-5); Serial.begin(115200); } When I flash the core the RTC is set correctly, however if I disconnect power or click the reset button on the Core it goes back to 1969-12-31 19:00:00 (as it should) But my core then should be running through the above lines to …

Also having a backup battery on VBAT pin lets Photon keep its RTC running when powered off. If you search for VBAT there are lenghty discussions about it, but somewhat confusing. Not having it would just have you wait for sync each time you power up your Photon. (note though, Core has no VBAT pin, if you by any chance have Spark Core too)

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [August 3, 2015, 8:55pm UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/3 "2015-08-03T20:55:08Z")

</div>

@helxsz, @lami, there is also the [Time.syncTime()](http://docs.particle.io/photon/firmware/#spark-synctime) command to force a cloud time sync. This is useful for updating the time every 24 hours for example. 😄

---

<div class="post-metadata">

**Author:** ![Awake](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@Awake](https://community.particle.io/u/Awake)\
**Post date:** [August 4, 2015, 3:49am UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/4 "2015-08-04T03:49:13Z")

</div>

Since there is a significant delay in setting up the initial time sync, is there a way to verify that a time sync has completed?  
I have a working display that is wrong for the first minute or so, and displays nonsense, after which it jumps to the correct time.  
I would like to only display the time after it has been properly setup.

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [August 4, 2015, 4:03am UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/5 "2015-08-04T04:03:50Z")

</div>

Hi @Awake

I think what a lot of folks are doing is wait for the year to greater than 1970.

---

<div class="post-metadata">

**Author:** ![lami](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/lami/32/3576_2.png) [@lami](https://community.particle.io/u/lami)\
**Post date:** [August 4, 2015, 5:21pm UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/6 "2015-08-04T17:21:10Z")

</div>

Yes there is, look into the thread I linked for code example. But it does exactly what @bko says.

---

<div class="post-metadata">

**Author:** ![maks78in](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@maks78in](https://community.particle.io/u/maks78in)\
**Post date:** [February 4, 2016, 1:49am UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/7 "2016-02-04T01:49:38Z")

</div>

Hi

I have a silly query.  
Why does RTC need to be synced with Cloud? Is it considered to unify the time value of all devices to a common reference?

Good day!

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [February 4, 2016, 12:19pm UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/8 "2016-02-04T12:19:13Z")

</div>

Yes, since the RTC might be running slow/fast or has lost power, so you would want it to sync with a common reference (UTC is the global reference time and hence used by Particle too).  
It’s not only the basis for all Particle devices but also for your wrist watch and your mobile phone and computer and …

---

<div class="post-metadata">

**Author:** ![maks78in](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@maks78in](https://community.particle.io/u/maks78in)\
**Post date:** [February 4, 2016, 5:32pm UTC](https://community.particle.io/t/how-should-the-photon-sync-the-time-with-the-cloud/14080/9 "2016-02-04T17:32:03Z")

</div>

Thank you @ScruffR for the response.
