How to add Time.timeStr() to a Sprintf string to then Particle Publish it?

Tags: #<Tag:0x00007fe22b14bbe8>


Hey guys!

What is the proper way to add a timestamp into a Sprintf String that will then be used in a Particle Publish event?

“Time.timeStr()” designated as “%s” formatting is not working.

snprintf(Status, sizeof(Status),  "%s:%s:%.2f:%u:%u:%u:%u:", Time.timeStr(),ID,lipoVoltage,Distance_Threshold_Passed,Light_Threshold_Passed,proximity_data,ambient_light);

If I wanted to use the Time.timeStr(), formatting instead of UNIX time what do I need to change?

I’ll keep looking for the answer but any help would be appreciated. :slight_smile:


If you look at the documentation it is confusing since the docs here says this function returns a String - however the sprintf parameter %s expects a string - these are different datatypes so you must convert to a C sting using



Yep, that worked perfectly :spark: