Simple example from the Time documentation. Just runs the RTC...

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 int main()
00004 {
00005     set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
00006 
00007     while(1) {
00008         time_t seconds = time(NULL);
00009         printf("Time as seconds since January 1, 1970 = %d\n", seconds);
00010         printf("Time as a basic string = %s", ctime(&seconds));
00011         char buffer[32];
00012         strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
00013         printf("Time as a custom formatted string = %s", buffer);
00014         wait(1);
00015     }
00016 }