ok

Dependencies:   mbed

Fork of time_HelloWorld by mbed official

main.cpp

Committer:
avnisha
Date:
2014-02-07
Revision:
1:bd5a5138e372
Parent:
0:b3b93997a0a6

File content as of revision 1:bd5a5138e372:

#include "mbed.h"

int main() {
    set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37

    while (true) {
        time_t seconds = time(NULL);
        
        printf("Time as seconds since January 1, 1970 = %d\r\n", seconds);
        
        printf("Time as a basic string = %s\r\n", ctime(&seconds));

        char buffer[32];
        strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
        printf("Time as a custom formatted string = %s\r\n", buffer);
        
        wait(60);
    }
}