An accurate enough way is to use the millis() function. It will return the value in milliseconds since the start of the Arduino. If you start the Arduino at a specific time, you will be able to calculate the exact date and time.


Why not an external module?? An RTC such as the DS3231 in merely 5$ and it includes a temperature sensor for you!

Answer from Dat Ha on Stack Exchange
🌐
Arduino
docs.arduino.cc › language-reference › en › functions › time › millis
millis() | Arduino Documentation
Returns the number of milliseconds passed since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days. Use the following function to get the exact time the board has been running the current program in milliseconds:
Discussions

How to display current time in Hour Minute Second Millisecond format in arduino?
Hello guys, how can I display current time in Arduino? I have tried using mills() but it only shows the date since reboot of the arduino in milliseconds, how do I get the current time in HH:MM:SS:Milliseconds? not the time after the last reboot More on forum.arduino.cc
🌐 forum.arduino.cc
9
0
April 25, 2018
Accessing the current date
Hi... complete noob here to Arduino and C++... I am having a heck of a time just trying to access the current date in my loop(). Any help is appreciated. I've pieced together the following code that connects to an NTP and adjusts for my timezone... this (borrowed) code seems to be working just fine. More on forum.arduino.cc
🌐 forum.arduino.cc
4
0
March 18, 2025
Time library functions with ESP32 core
Does anyone now what the equivalent of the following is with ESP32 core? The time example is useless - all it does is use a function to print the current time to serial monitor. And I find it difficult to believe that this is the only thing you can do with ESP32 time library. More on forum.arduino.cc
🌐 forum.arduino.cc
19
1
March 20, 2018
measuring time
i have to measure time in arduino.I think i should use stopwatch library but i didn't include this library in my computer.Maybe you can help me.thanks More on forum.arduino.cc
🌐 forum.arduino.cc
19
0
March 28, 2012
🌐
Reddit
reddit.com › r/arduino › get current time in arduino?
r/arduino on Reddit: Get current time in arduino?
December 1, 2015 -

Hello,

I want to measure the time that takes to transmit a package from arduino to a device connected to the computer. I've thought about taking the current time in arduino when I send the package and take the current time in the Java app that is running in the computer when it receives a packet and then calculate the difference. There is no problem to take the current time in the Java part, but in the arduino's one I don't know how to do it. I've tried the Time library but if I use the now() method I get the time since the code is running. For example I've a delay of 5 seconds in the setup() and then I call the now() method and it returns 5.

Anyone know how to get the current time or have any idea to calculate the transmision time between the two devices?

Thanks!

🌐
Circuit Basics
circuitbasics.com › using-an-arduino-ethernet-shield-for-timekeeping
How to Get the Date and Time on an Arduino
October 22, 2024 - To install the Time library, search and install the library “Time” by Michael Margolis from the IDE’s Library Manager. See Figure 2 below as a guide. Figure 3. Arduino IDE Library Manager · After installing the libraries into the IDE, use keyword #include to add them to our sketch. // Using An Arduino Ethernet Shield To Get Date and Time #include <SPI.h> // for communication with Ethernet Shield #include <TimeLib.h> // for update/display of time #include <Ethernet.h> // for communication with NTP Server via UDP
🌐
Instructables
instructables.com › circuits › arduino
Arduino Timing Methods With Millis() : 4 Steps - Instructables
July 17, 2019 - Arduino Timing Methods With Millis(): In this article we introduce the millis(); function and put it to use to create various timing examples. Millis? Nothing to do with lip-syncers… hopefully you recognised milli as being the numerical prefix for one-thousandths; that is multiplying a …
🌐
Arduino Forum
forum.arduino.cc › projects › programming
How to display current time in Hour Minute Second Millisecond format in arduino? - Programming - Arduino Forum
April 25, 2018 - Hello guys, how can I display current time in Arduino? I have tried using mills() but it only shows the date since reboot of the arduino in milliseconds, how do I get the current time in HH:MM:SS:Milliseconds? not the ti…
Find elsewhere
🌐
Programming Electronics Academy
programmingelectronics.com › home › millis() arduino function: 5+ things to consider
millis() Arduino function: 5+ things to consider - Programming Electronics Academy
April 6, 2023 - So every time the Arduino goes through its loop, this variable will be updated with the most recent count of time in milliseconds. We see this when we print this variable to serial monitor. After 1 minute of being powered up, the variable will be equal to 60,000 (60 secs x 1000 ms). If you waited 7 days, the value “returned” would be 604,800,000 (7 days x 24 hours x 60 min x 60 secs x 1000 ms). Another way to get the value of millis() is to call the function inside of a condition.
🌐
DEV Community
dev.to › snorri1986 › time-functions-in-arduino-uno-31a5
Time functions in Arduino Uno - DEV Community
July 30, 2025 - Arduino Uno has minimum two functions which help to get current time mark from the beginning: millis() and micros(). millis() returns time marks in milliseconds. micros() returns time marks in microseconds.
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Accessing the current date - Programming - Arduino Forum
March 18, 2025 - Hi... complete noob here to Arduino and C++... I am having a heck of a time just trying to access the current date in my loop(). Any help is appreciated. I've pieced together the following code that connects to an NTP and adjusts for my timezone... this (borrowed) code seems to be working just fine.
🌐
Seeed Studio
wiki.seeedstudio.com › xiao › getting started with seeed studio xiao esp32-s3 series
Getting Started with Seeed Studio XIAO ESP32-S3 Series | Seeed Studio Wiki
May 14, 2026 - Combining embedded ML computing power and photography capability, this development board can be your great tool to get started with intelligent voice and vision AI. ... The OV2640 camera has been discontinued, and the subsequent XIAO ESP32-S3 Sense uses the OV3660 camera model.However, the Wiki example code for the camera still applies. Powerful MCU Board: Incorporate the ESP32S3 32-bit, dual-core, Xtensa processor chip operating up to 240 MHz, mounted multiple development ports, Arduino / MicroPython supported
🌐
Arduino Forum
forum.arduino.cc › projects › programming
Time library functions with ESP32 core - Programming - Arduino Forum
March 20, 2018 - Does anyone now what the equivalent of the following is with ESP32 core? The time example is useless - all it does is use a function to print the current time to serial monitor. And I find it difficult to believe that …
🌐
Hackaday
hackaday.com › 2026 › 04 › 23 › kerneluno-an-os-for-the-arduino-uno
KernelUNO, An OS For The Arduino Uno | Hackaday
April 29, 2026 - To paraphrase my understanding, the absolute minimum requirement in the context of an Arduino is that you have: – A timed interrupt routine that switches tasks – A kernel function that does some hardware abstraction like toggling IO pins – At least one other function that contains your program.
🌐
Electronic Wings
electronicwings.com › arduino › basic-functions-related-to-time-and-interrupts-in-arduino
Basic functions related to Time and Interrupts in Arduino | Ardu..
This function returns the number of microseconds passed since the Arduino board started running the current program. This number overflows (rolls back to zero) after approximately 70 minutes.
🌐
Qualcomm
qualcomm.com
Wireless Technology & Innovation | Mobile Technology | Qualcomm
Learn how Qualcomm transforms industries with leading edge AI, high-performance, low-power computing and unrivaled connectivity.
🌐
Arduino Forum
forum.arduino.cc › other hardware › science and measurement
measuring time - Science and Measurement - Arduino Forum
March 28, 2012 - i have to measure time in arduino.I think i should use stopwatch library but i didn't include this library in my computer.Maybe you can help me.thanks
🌐
Quora
quora.com › How-can-I-get-the-current-time-on-arduino
How to get the current time on arduino - Quora
Answer (1 of 4): There are many RTC ICs available. Some communicate using i2c and some using SPI. One of the most common rtc for arduino is ds1307 from dallas/maxim. It communicates via i2c and has a fully functional library in arduino.
🌐
Random Nerd Tutorials
randomnerdtutorials.com › home › project › esp32 › getting date and time with esp32 on arduino ide (ntp client)
Getting Date and Time with ESP32 (NTP Client) | Random Nerd Tutorials
June 12, 2024 - In your Arduino IDE, go to Sketch > Include Library > Add . ZIP library… · Select the .ZIP file of the library you just downloaded. The library will be installed after a few seconds. Here we provide a sample code to get date and time from the NTP Server.
🌐
CDC
cdc.gov › adenovirus › about › index.html
About Adenovirus | Adenovirus | CDC
December 16, 2025 - Adenoviruses can cause illness in people of all ages any time of year.
🌐
Stack Overflow
stackoverflow.com › questions › 35923471 › get-current-time-in-arduino-1-6-6
Get current time in arduino 1.6.6 - Stack Overflow
The first and most common is to use a real time clock (RTC). There are plenty of them, but I usually use the maxim ones. You can get one with internal or external crystal, with or without battery to keep the time...
🌐
Random Nerd Tutorials
randomnerdtutorials.com › home
Random Nerd Tutorials | Learn ESP32, ESP8266, Arduino, and Raspberry Pi
April 9, 2025 - Random Nerd Tutorials helps makers, hobbyists and engineers build electronics projects. We make projects with: ESP32, ESP8266, Arduino, Raspberry Pi, Home Automation and Internet of Things. If you want to learn electronics and programming, you're in the right place.