You can get the current date adding the following line in your sketch:
system("date > /dev/ttyGS0");
This line will run the command "date" in the Linux terminal and redirect its output to the USB client port. If you have the Serial Monitor opened the date will be printed on it.
Thanks for useful info.
Actually in my project I am taking sensor values...
I want to print the sensor value in one column and Timestamp in another column..
How to get this value into a variable or directly printing using "client.println" to send it to webpage using Ethernet web server?
When you use the system() function you will be able to run the Linux commands from the Arduino IDE, however there is no way you can store an output of a Linux command in a variable created in the Arduino environment directly. The only way I know you can get the output of a Linux command in a variable created in the Arduino environment is the following:
- You should run the Linux command from the Arduino IDE using the system() function. You have to redirect the output to a file. This file will be created in the Linux side and the data will be written in it.
- Once the file is created and the data is in it, you have to open the file and read it from the Arduino IDE.
- The data read from the file has to be stored in a variable created in the Arduino IDE. Then you will be able to manipulate this data and print it in the way you want.