Comments (4)
The tmElements_t data structure you are creating is not valid.
Keep in mind that the years in a tmElements structure are since 1970 and that the months start at 1 (for January) as do the days.
I hope this helps.
from time.
Thanks for your help.
But I don't think this would be a problem as the time_t means how many seconds has passed after 1/1/1970.
Also, When I change the day to 1, month to 1, year to 1970, it returns 1322155904 which is 17:31:44 11-24-2011, it just totally doesn't make sense.
from time.
Would you mind try this or similar code on your Arduino? As it's possible because something wrong with my IDE on the computer. But it didn't help even after I reinstalled this Time library.
from time.
Indeed your error is use of 0 for tm.Day and tm.Month.
I just tested this code:
#include <Time.h>
void setup() {
Serial.begin(9600);
}
void loop() {
setTime(sync());
Serial.print(now());
Serial.print(" ");
Serial.print(hour());
Serial.print(':');
Serial.print(minute());
Serial.print(':');
Serial.print(second());
Serial.print(' ');
Serial.print(month());
Serial.print('-');
Serial.print(day());
Serial.print('-');
Serial.println(year());
delay(500);
}
time_t sync() {
tmElements_t tm;
tm.Hour = 0;
tm.Minute = 0;
tm.Second = 0;
tm.Day = 1;
tm.Month = 1;
tm.Year = 0;
return makeTime(tm);
}
This is the result in the serial monitor:
0 0:0:0 0-0-1970
0 0:0:0 0-0-1970
0 0:0:0 0-0-1970
0 0:0:0 0-0-1970
0 0:0:0 0-0-1970
Time is working properly. You simply used 0 in those fields which begin at 1.
from time.
Related Issues (20)
- Time.h and time.h issue on windows HOT 4
- v1.6.1 contains a breaking change for v1.6.0 clients; Semver suggests v2.0.0 tag. HOT 1
- Set system time so LittleFS can take over the real time
- error with DCF77 library: 'now' was not declared ..... in version 1.6.1 HOT 1
- TimeLib conflicts with NeoGPS library HOT 2
- 12/31/2097 HOT 1
- Issues compiling library with Arduino WEB IDE HOT 1
- Issue with setting time on arduino every HOT 1
- adjustTime increments a leap year when it shouldn't. HOT 1
- on pico set wire clock
- getNtpTime() doesn't handle zero from NTP server response HOT 1
- How to blink colon separator (:) every 500 millis..?
- Issue compiling on ESP32 with latest ESP32 library (2.0.6)
- convert timestamp to date and time ? HOT 1
- Combine hour() and minute() in HHMM format
- bug in minutesToTime_t macros HOT 2
- Epoch and Time offset HOT 3
- Time to deprecate TinyGPS
- How to disable setSyncInterval
- Error Date february 29/02/2024 but show 01/03/2024
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from time.