user48730: I write code to upload to ESP8266. I wish to use time stamp in order to log events. I found an NTP sketch, I can work with ( since it has a wifi connection ), but I wish to keep my code as simple as possible.
So I'm thinking to use my MQTT server to send time updates from time to time ( have a certain topic for that ), and in between updates, use millis() .
Since I'm new here, I want to know from experienced programmer if it makes sense ? 
I would love to hear pros and cons ( before I start coding ).
Any help will be appreciated,
Guy

user37622: Use the Time library a.k.a. TimeLib.h. It will keep time between calls to your source of time, if it is your MQTT call or NTP server. 
In your code you will use the Time library to get time and the source of the current time is independent from the rest of the code. 
The TimeLib has a function setTime to set the current time and then it keeps the time using millis(). You can update the time by calling setTime again. The timestamp value for setTime is 'Unix Epoch' - number of seconds from "1970-01-01 00:00:00".
If you decide to add NTP to your project, you can use NtpClientLib. It sets the time to TimeLib with one simple line of code in setup(). Example NTP.begin("pool.ntp.org", 1, false);.

48730: <p>I write code to upload to ESP8266. I wish to use time stamp in order to log events. I found an NTP sketch, I can work with ( since it has a wifi connection ), but I wish to keep my code as simple as possible.</p>

<p>So I'm thinking to use my MQTT server to send time updates from time to time ( have a certain topic for that ), and in between updates, use <code>millis()</code> .</p>

<p>Since I'm new here, I want to know from experienced programmer if it makes sense ? 
I would love to hear pros and cons ( before I start coding ).</p>

<p>Any help will be appreciated,</p>

<p>Guy</p>
 37622: <p>Use the Time library a.k.a. TimeLib.h. It will keep time between calls to your source of time, if it is your MQTT call or NTP server. </p>

<p>In your code you will use the Time library to get time and the source of the current time is independent from the rest of the code. </p>

<p>The TimeLib has a function <code>setTime</code> to set the current time and then it keeps the time using millis(). You can update the time by calling <code>setTime</code> again. The timestamp value for <code>setTime</code> is 'Unix Epoch' - number of seconds from "1970-01-01 00:00:00".</p>

<p>If you decide to add NTP to your project, you can use NtpClientLib. It sets the time to TimeLib with one simple line of code in setup(). Example <code>NTP.begin("pool.ntp.org", 1, false);</code>.</p>
