time Hello World

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     set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
00005 
00006     while (true) {
00007         time_t seconds = time(NULL);
00008         
00009         printf("Time as seconds since January 1, 1970 = %d\n", seconds);
00010         
00011         printf("Time as a basic string = %s", ctime(&seconds));
00012 
00013         char buffer[32];
00014         strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
00015         printf("Time as a custom formatted string = %s", buffer);
00016         
00017         wait(1);
00018     }
00019 }