Can I call a function from setup?

I have a project that I am working on where I need to access a NTP server to get the time, but only once at the time that the Arduino boots up. Can I do this by creating a function and calling it from void setup() so that it only does this when the Arduino boots up?

yep. I am doing that myself. just make sure that the wifi and everything else is set up prior to trying to make that call.

ve3joc: I have a project that I am working on where I need to access a NTP server to get the time, but only once at the time that the Arduino boots up. Can I do this by creating a function and calling it from void setup() so that it only does this when the Arduino boots up?

Didn't it occur to you that you could try?

Can I do this by creating a function and calling it from void setup()

You are almost certainly calling other functions such as pinMode(), Serial.begin() etc from setup() so why would you think that calling your function might not be possible ?

You could have tried it almost as quickly as posting your message

Hmmmm... One helpful reply and two sarcastic ones.

Yes, it did occur to me that I could try it but being reasonably new at programming the Arduino, and also not familiar with accessing an NTP server, I was not sure if other things had to be up and running before making the call to the function, something that theskaz kindly pointed out. Take a peek at my profile,... it says Newbie! I suppose I could have been a bit clearer about what I wasn't sure about.

Thanks for the help theskaz. Much appreciated.

I was not sure if other things had to be up and running before making the call to the function

Even if other things needed to be running before calling the function you could do that in setup() too.

Sometimes you want to test only one thing only once. You then end up with a function call (or even several) in the setup and an empty loop. This also is possible.

ve3joc: Take a peek at my profile,... it says Newbie!

That just tells us you have fewer than a fairly small number of posts here on the forum, and nothing else.