0

Well, googling didn't do much to help me here and I'm shocked that something I can do in two lines of code in C#

DateTime dateTime;
string text = dateTime.ToLongDateString();    

is this difficult for Arduino, but how do you get a string version of a date time stamp?

I want the current date and time as a string in this format

May 4, 2016 17:15:33

Since I can't use any of the C++ includes, like ctime, I'm not sure how to accomplish this.

  • I found a great library for this very purpose! github.com/PaulStoffregen/Time – dinotom May 5 '16 at 0:21
  • But I can't get any of the examples to work on an Uno – dinotom May 5 '16 at 0:32
  • 3
    Which examples did you try? What results did you get? – TisteAndii May 5 '16 at 1:58
  • 1
    What time do you want to get? The Arduino has no concept of the time, unless you add an RTC module, and then it is down to whatever library the RTC module uses. – Majenko May 5 '16 at 8:46
  • I wasn't aware of that. So an additional hardware piece(RTC) is required to capture time? I'll look into that – dinotom May 5 '16 at 8:53
1

You need additional hardware like a RTC for example an DS1307 or on the other hand an arduino/shield with ethernet or wifi so you could get the time by NTP another option might be DCF77 time via the air - sorry forgot GPS could also be used to get the time .... the rest then should be simple creating a string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.