Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 6 months ago.
Bug in the real time clock?
Using the example programs given in the link: https://os.mbed.com/blog/entry/10
#include "mbed.h" int main() { while(1) { time_t seconds = time(NULL); printf("Time as seconds since January 1, 1970 = %d\n", seconds); printf("Time as a basic string = %s", ctime(&seconds)); char buffer[32]; strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); printf("Time as a custom formatted string = %s", buffer); wait(1); } }
the output is:
Time as a custom formatted string = 12:00 AM
Time as seconds since January 1, 1970 = -1
Time as a basic string = Sun Jan 1 00:00:00 1900
Anyone else having trouble with this?
1 Answer
5 years, 6 months ago.
Mike - there must be more than 100 posts on this subject. You didn't mention which board you are working on. NXP? ST? Other? There are some settings needed for most of the boards and of course a battery if you want it to work when power is restored. Bill