![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fecha y Hora en formato unix
Revision 0:85438fce9445, committed 2020-05-19
- Comitter:
- Diego_Mbed
- Date:
- Tue May 19 02:29:04 2020 +0000
- Commit message:
- Fecha y hora en Formato UNIX;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 85438fce9445 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 19 02:29:04 2020 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" + +Serial pc(SERIAL_TX, SERIAL_RX); + +int main() { + set_time(1589387262); // Set RTC time to Wed, 28 Oct 2009 11:35:37 + + while (true) { + time_t seconds = time(NULL); + + pc.printf("Time as seconds since January 1, 1970 = %u\n\r", (unsigned int)seconds); + + pc.printf("Time as a basic string = %s\n\r", ctime(&seconds)); + + char buffer[32]; + strftime(buffer, 32, "%I:%M %p\n\r", localtime(&seconds)); + pc.printf("Time as a custom formatted string = %s\n\r", buffer); + + wait(3); + } +} + +
diff -r 000000000000 -r 85438fce9445 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue May 19 02:29:04 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file