Which datetime PHP format should I use best?
- DonZalmrol
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
- Thank you received: 6
2 years 2 months ago - 2 years 2 months ago #6238
by DonZalmrol
Which datetime PHP format should I use best? was created by DonZalmrol
Hi,
From the radmon.org API topic I see that "datetime" can be used to upload your precise datetime of your logging entry into the Radmon DB.
https://radmon.org/index.php/forum/howtos-and-faqs/864-radmon-org-api
Under the notes it says
When I upload the Unix epoch time I get a 400 (Bad Request response status code) error for my upload, which is odd as an epoch should be an accepted PHP format. If this is not the case, what notation for date & time should I use best?
My code is simple, so that should not be the issue at hand, and when I comment the datetime part it works fine like it always has.
Thanks!
From the radmon.org API topic I see that "datetime" can be used to upload your precise datetime of your logging entry into the Radmon DB.
https://radmon.org/index.php/forum/howtos-and-faqs/864-radmon-org-api
Under the notes it says
Since my current connection is a bit intermittent I would like to start using this.The datetime parameter should be in a PHP parseable format. It is for uploading data that is stored due to intermittent network access.
When I upload the Unix epoch time I get a 400 (Bad Request response status code) error for my upload, which is odd as an epoch should be an accepted PHP format. If this is not the case, what notation for date & time should I use best?
My code is simple, so that should not be the issue at hand, and when I comment the datetime part it works fine like it always has.
// Upload data to the RadMon.org server
static void connecToRadMonLogger(void)
{
esp_task_wdt_add(NULL);
WiFiClient wifi;
HttpClient client = HttpClient(wifi, "radmon.org", 80);
Serial.println(F("Connection to radmon monitoring platform succeeded!"));
// Concat data for POST
// API URL
String ptr = "/radmon.php?function=submit";
ptr += "&user=";
ptr += UserName;
ptr += "&password=";
ptr += DataSendingPassWord;
ptr += "&value=";
ptr += String(cpm);
ptr += "&unit=CPM";
ptr += "&datetime=";
ptr += String(epoch);
// Test output
//Serial.println("Uploaded CPM = " + String(cpm));
Serial.println("created PTR = " + ptr);
client.beginRequest();
client.post(ptr);
client.sendHeader("Content-Type", "application/x-www-form-urlencoded");
client.sendHeader("Content-Length", ptr.length());
client.beginBody();
client.print("");
client.endRequest();
// read the status code and body of the response
statusCodeRadmon = client.responseStatusCode();
// Give the client some time to stop
yield();
esp_task_wdt_delete(NULL);
Serial.println(F("Connection to radmon monitoring platform Disconnected."));
Serial.println(F("\n"));
}
Thanks!
Last edit: 2 years 2 months ago by DonZalmrol. Reason: wrong code formatting
Please Log in or Create an account to join the conversation.
2 years 1 month ago #6264
by Simomax
Replied by Simomax on topic Which datetime PHP format should I use best?
It is not required that you POST the datetime as the Radmon server does this automatically when submitting a CPM value.
PHP datetime without additional formatting is generally as 'Y-m-d H:i:s', so now would be '2022-11-12 10:19:32'. However, I don't know if this is the exact format that Radmon expects as I have never used it. In the API documentation it states 'The datetime parameter should be in a PHP parseable format. It is for uploading data that is stored due to intermittent network access.' Unless you are working offline then unloading a bulk of readings to Radmon then the datetime field is not required, is my understanding.
PHP datetime without additional formatting is generally as 'Y-m-d H:i:s', so now would be '2022-11-12 10:19:32'. However, I don't know if this is the exact format that Radmon expects as I have never used it. In the API documentation it states 'The datetime parameter should be in a PHP parseable format. It is for uploading data that is stored due to intermittent network access.' Unless you are working offline then unloading a bulk of readings to Radmon then the datetime field is not required, is my understanding.
Please Log in or Create an account to join the conversation.
Moderators: Gamma-Man
Time to create page: 0.123 seconds