Convert long long or uint64 to string?

I am dealing with a sensor that timestamps the outgoing data using a string of characters in this format:
yyyymmddhhnnssW or yyyymmddhhnnssS depending on daylight savings setting.
Disregarding the W/S specifier I have a 14 character long numeric string, which I save into a long long (64 bit) variable since it will not fit into a long int.
Then later I need to make a MQTT packet of this value and now I have failed in finding any C/C++ conversion function that can give me a string representation of this long long (or uint64) value.

I have tried:

String LongLongToString(uint64 value)
{
	char buf[25];
	memset(buf, 0, sizeof(buf));

	long lo = value % 10000000;
	long hi = value / 10000000;
	snprintf(buf, sizeof(buf), "%0.7l%0.7l", hi, lo);
	return String(buf);
}

But it returns these warnings:

src\utils.cpp: In function 'String LongLongToString(uint64)':
src\utils.cpp:83:49: warning: conversion lacks type at end of format [-Wformat=]
  snprintf(buf, sizeof(buf), "%0.7l%0.7l", hi, lo);
                                                 ^
src\utils.cpp:83:49: warning: conversion lacks type at end of format [-Wformat=]
src\utils.cpp:83:49: warning: too many arguments for format [-Wformat-extra-args]
src\utils.cpp:83:49: warning: conversion lacks type at end of format [-Wformat=]
src\utils.cpp:83:49: warning: conversion lacks type at end of format [-Wformat=]
src\utils.cpp:83:49: warning: too many arguments for format [-Wformat-extra-args]

Please advice what I should do!

Why do you need to convert it back when you started with a string representation ?

[quote="BosseB, post:1, topic:1053377"]
sensor that timestamps the outgoing data using a string of characters ...
I save into a long long (64 bit) variable[/quote]
why not just handle it as a string of characters (or bytes)? wouldn't the S attributes also work with that approach?

here I make a string out of several datas, unit64_t's, before sending mqtt

      xSemaphoreTake( sema_eData, portMAX_DELAY );
      struct stu_eData px_eData = x_eData;
      xSemaphoreGive( sema_eData );
      String sTopic = "";
      sTopic.reserve( 35 );
      sTopic.concat( String(px_eData.SunRiseHr) + "," );
      sTopic.concat( String(px_eData.SunRiseMin) + "," );
      sTopic.concat( String(px_eData.SunSetHr) + "," );
      sTopic.concat( String(px_eData.SunSetMin) + "," );
      sTopic.concat( String(px_eData.DawnHr) + "," );
      sTopic.concat( String(px_eData.DawnMin) + "," );
      sTopic.concat( String(px_eData.TransitHr) + "," );
      sTopic.concat( String(px_eData.TransitMin) );
      xSemaphoreTake( sema_MQTT_KeepAlive, portMAX_DELAY );
      MQTTclient.publish( topicSRSSDDT, sTopic.c_str() );
      xSemaphoreGive( sema_MQTT_KeepAlive );

that's the real question

to answer the technical question, try this typical ulltoa() implementation

char *ulltoa(uint64_t value, char *buf, int radix) {
	char tmp[64 + 1];
	char *p1 = tmp, *p2;
	static const char xlat[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	if(radix < 2 || radix > 36)	return nullptr;
	do {*p1++ = xlat[value % (unsigned)radix];} while((value /= (unsigned)radix));
	for(p2 = buf; p1 != tmp; *p2++ = *--p1) ;
	*p2 = '\0';
	return buf;
}



void setup() {
  char buffer[65];
  Serial.begin(115200);
  uint64_t x = 1234567890123456789ull;
  Serial.println(ulltoa(x, buffer, 10));

  x = 0xFF00FF01FF02FF03;
  Serial.print("0x"); Serial.println(ulltoa(x, buffer, 16));
}

void loop() {}

There also seems to be the usual confusion between strings and Strings

Because all of the data returned from the device are converted into global long values and the timestamp is much longer so it does not fit.
And this part is not written by me but downloaded from GitHub, I am just adding extra database storage functions etc...
And the timestamp was not handled in the original sketch so I figured I should just add one more item in the same way as all of the others.

But I assume I could make a special case and separate them into yyyymmdd in one long and hhnnss in another long, this way I would have to just concatenate two items that can be handled in the "normal" way all other values are processed.

I assume by that you mean the data consists of ASCII characters that represent single digits with a final W / S at the end? If that's the case, why in the world are your shoving it into a uint64_t? Use an array of char and parse it after the complete string is received.

"l" does not tell how to format the argument, just how big it is. Use "ld".

the algorithm does not work anyway

the max value of a uint64_t is 18,446,744,073,709,551,615

so dividing by 10 million gives 1,844,674,407,370 which is way above what a 32 bit unsigned int can represent as the max value of a uint64_t is 4,294,967,295

However it is sufficient in this case:

But in general, something like post #5 is preferable.

Back on this again...
I have tried to simplify things by splitting the timestamp into two long variables:
HANTIMESTAMP_DAY and HANTIMESTAMP_TIME each will be set to a value like 221114 and 131447 for date and time.
They are declared like this:

long HANTIMESTAMP_DAY;
long HANTIMESTAMP_TIME;

Now I need to combine these into a value string for mqtt and tried this:

    String output = "";
    output += String(HANTIMESTAMP_DAY, 6);  //long HANTIMESTAMP_DAY = 221114
    output += String(HANTIMESTAMP_TIME, 6); //long HANTIMESTAMP_TIME = 135412
    String topic = String(MQTT_ROOT_TOPIC); //MQTT_ROOT_TOPIC = "sensors/power/p1meter"
    topic += "/timestamp";
    send_mqtt_message(topic.c_str(), output.c_str());

But the word output. on the last line gets a red wiggly underline indicating a syntax error:

error: invalid conversion from 'const char*' to 'char*' [-fpermissive]

The called function is defined like this:

void send_mqtt_message(const char *topic, char *payload)

What can I do?

Fix the function so it takes a "const char*".

If that is not possible, copy the value of the String into a char buffer and pass the address of the buffer.

    char buffer[output.length() + 1];
    output.toCharArray(buffer, sizeof buffer);
    send_mqtt_message(topic.c_str(), buffer);

String is a User-defined data type; whereas, string is a vocabulary which refers to an array of null-ended ASCII codes. Am I correct?

You know very well what the difference is between a String and a string in the context of an Arduino sketch

I was referring to the original post where we are told this

only to have him/her post code that returns a String

String LongLongToString(uint64 value)
{

I'm still puzzled about using a uint64_t in the first place.