# PC time

**URL:** <https://forum.arduino.cc/t/pc-time/606499>\
**Category:** Programming\
**Created:** [August 15, 2019, 3:29pm UTC](https://forum.arduino.cc/t/pc-time/606499 "2019-08-15T15:29:38Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mebab](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mebab/32/1060493_2.png) [@mebab](https://forum.arduino.cc/u/mebab)\
**Post date:** [August 15, 2019, 3:29pm UTC](https://forum.arduino.cc/t/pc-time/606499/1 "2019-08-15T15:29:38Z")

</div>

Hi,

I am looking for a simple way to retrieve the pc clock date/time on arduino101 by using the normal USB connection, without any extra hardware. I will use the clock data to synch my RTC afterward.

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [August 15, 2019, 3:55pm UTC](https://forum.arduino.cc/t/pc-time/606499/2 "2019-08-15T15:55:45Z")

</div>

To do what you want there needs to be some software running on the PC to send the time data to the Arduino.

---

<div class="post-metadata">

**Author:** ![mebab](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mebab/32/1060493_2.png) [@mebab](https://forum.arduino.cc/u/mebab)\
**Post date:** [August 15, 2019, 7:56pm UTC](https://forum.arduino.cc/t/pc-time/606499/3 "2019-08-15T19:56:44Z")

</div>

Do you know what software is needed?

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [August 15, 2019, 8:20pm UTC](https://forum.arduino.cc/t/pc-time/606499/4 "2019-08-15T20:20:15Z")

</div>

You were just told what software is needed.

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [August 15, 2019, 10:35pm UTC](https://forum.arduino.cc/t/pc-time/606499/5 "2019-08-15T22:35:46Z")

</div>

It's unlikely you will find a ready made application that does this. Instead you would probably need to create your own and that could be done in numerous ways. The best way to proceed with that would depend on whether there are any programming languages or frameworks used to create PC applications that you're currently familiar with. For example, if you're skilled in Python, then the obvious choice would be to use Python.

If tell us what experience, if any, you currently have that could be applied to this project. We may be able to use that information to provide you with more specific advice.

---

<div class="post-metadata">

**Author:** ![evanmars](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/evanmars/32/217678_2.png) [@evanmars](https://forum.arduino.cc/u/evanmars)\
**Post date:** [August 15, 2019, 11:05pm UTC](https://forum.arduino.cc/t/pc-time/606499/6 "2019-08-15T23:05:46Z")

</div>

Maybe with Processing

> **[hour() / Reference](https://processing.org/reference/hour_.html)**
>
> Processing communicates with the clock on your computer. The hour() function returns the current hour as a value from 0 - 23.

```cpp
int s = second();  // Values from 0 - 59
  int m = minute();  // Values from 0 - 59
  int h = hour();

```

Then send it to Arduino.

---

<div class="post-metadata">

**Author:** ![noweare](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/noweare/32/987856_2.png) [@noweare](https://forum.arduino.cc/u/noweare)\
**Post date:** [August 16, 2019, 1:32am UTC](https://forum.arduino.cc/t/pc-time/606499/7 "2019-08-16T01:32:35Z")

</div>

> Paul\_KD7HB:  
> You were just told what software is needed.

What was that software ?

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [August 16, 2019, 1:40am UTC](https://forum.arduino.cc/t/pc-time/606499/8 "2019-08-16T01:40:44Z")

</div>

Obviously you didn't read my reply, where I clearly explain the situation and ask for some information so that we can help you further.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@SteveMann](https://forum.arduino.cc/u/SteveMann)\
**Post date:** [August 16, 2019, 3:22am UTC](https://forum.arduino.cc/t/pc-time/606499/9 "2019-08-16T03:22:14Z")

</div>

My solution may be a sledgehammer solution,, but since I already use MQTT in many of the nodes around the house, it was a simple task to have NodeRed publish the time every ten seconds to topics time12 and time24 (12-- and 24-hour format respectively).

I could sent it more often than every ten seconds, but it suits my needs.

---

<div class="post-metadata">

**Author:** ![DrAzzy](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DrAzzy](https://forum.arduino.cc/u/DrAzzy)\
**Post date:** [August 16, 2019, 3:29am UTC](https://forum.arduino.cc/t/pc-time/606499/10 "2019-08-16T03:29:21Z")

</div>

It seems like there has to be some standard solution here, since people buy RTC modules all the time and use them. How do they get the time into it initially?

---

<div class="post-metadata">

**Author:** ![bperrybap](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bperrybap/32/605367_2.png) [@bperrybap](https://forum.arduino.cc/u/bperrybap)\
**Post date:** [August 16, 2019, 4:17am UTC](https://forum.arduino.cc/t/pc-time/606499/11 "2019-08-16T04:17:23Z")

</div>

> DrAzzy:  
> It seems like there has to be some standard solution here, since people buy RTC modules all the time and use them. How do they get the time into it initially?

I've seen several cases of a specialized sketch to do this, some RTC libraries even include it.  
It uses the compile time of the sketch to set the time.  
i.e. the **DATE** and **TIME** strings.  
It parses those and uses it to set the time.  
It is one time thing that you compile and run when you need to set the time.

These days if you have an Arduino that has WiFi like the ESP modules, you can use NTP to get the time.  
You don't even need an RTC. Or you can use an RTC and set it using NTP.

If it is desired to get timing information over USB (assuming that means a virtual serial session), then, as UKHeliBob pointed out some sort of s/w is needed on the host to send the time information out the virtual serial port over the USB interface and then the Arduino must receive it and parse it.  
The common TimeLib library includes an example (TimeRTCset.ino) to parse time information from the serial port from a host.  
On \*nix systems it is easy to spit out the information. It can also be done on Windows based systems but it isn't as simple to get the desired output format re-directed to the needed serial port.

--- bill

---

<div class="post-metadata">

**Author:** ![mebab](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mebab/32/1060493_2.png) [@mebab](https://forum.arduino.cc/u/mebab)\
**Post date:** [August 16, 2019, 4:37am UTC](https://forum.arduino.cc/t/pc-time/606499/12 "2019-08-16T04:37:08Z")

</div>

Thanks a lot for all the comments. I will try the suggestions.

Bests  
Mebab

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 11:59pm UTC](https://forum.arduino.cc/t/pc-time/606499/13 "2021-05-05T23:59:00Z")

</div>

Closed on May 5, 2021, 11:59pm UTC


