Arduino sketch- How to add Time Stamp for outgoing MQTT
Start with the ESP8266WiFi "NTPClient" example.  That will teach you how you can get the "Unix Epoch" time from the internet.

That value can be fed directly into TimeLib to keep track of the time for you (indeed, TimeLib includes an NTP example for Arduino Ethernet that should help you get started).  Do that periodically (daily, hourly, whatever), and you have your time.  TimeLib can then give you the date and time as individual components (hours, minutes, etc), which you can then construct together (I'd use snprintf) to include in your MQTT message:

int len = strlen(message) + 25;
char mqttMessage[len];
snprintf(mqttMessage, len, "[%04d/%02d/%02d %02d:%02d:%02d] %s",
    year(), month(), day(), hour(), minute(), second(), message);

mqttMessage =&gt; "[2018/08/11 20:36:24] foo"