How to get the NTP Time

Hi there,

I’m working on a raspberry Pi Zero W and I want to activate a GPIO pin in a particular moment in time.

I’m building an home garden water system and I want to activate a pump ( connected to a GPIO) at 8 PM every day.

I think that could achive this goal using the time obtained by an NTP server.

Could anyone suggest me how to obtain the NTP time? Is there a library to do that?



What’s wrong with the native time functions?

1 Like

Thanks Moors.

I think to get the time from an NTP but I don’t know the easiest way that you suggested.

It’s very quick.


I think you could use the date command on Raspberry Pi:

// Get entire output of program
Process proc = Process::run("date");
String date = proc.out().readString();

You would get something like:

Sat Jul  1 12:36:06 EDT 2017

As the response.