> > time_t my_timestamp()
> > {
> > time_t t;
> > MYSQL_RES *tres;
> > MYSQL_ROW trow;
> >
> > if (mysql_query(SQLdb, "SELECT UNIX_TIMESTAMP()") == 0)
> > if ((tres = mysql_store_result(SQLdb)) != NULL)
> > if ((trow = mysql_fetch_row(tres)) != NULL) {
> > t = (time_t)atol(trow[0]);
> > mysql_free_result(tres);
> > return(t);
> > }
> > return((time_t)0); /* failure */
> > }
> >
>
> Function seems OK, except that I do not see how you connect and where
> do you call mysql_close...
OPS! of course I connect and close before and after calling this function :-)
So is this the fastest way to get the unix timestamp of server?
What about a C API interface that does the same thing, i.e. something like
mysql_time() that just returns server's UNIX time? :-)
I could hack this one myself but I think it could be useful to other people
too...
Thanks
Rick
--
Riccardo Pizzi, Network Engineer @ adhoc.net
AD HOC Network High Quality ISP, Rimini, ITALY
Phone: +39-0541-382488 Fax: +39-0541-306910