> Erlang中文手册 > time/0 获取当前时间

erlang:time/0

获取当前时间

用法:

time() -> {Hour, Minute, Second}

内部实现:

BIF_RETTYPE time_0(BIF_ALIST_0)
{
     int hour, minute, second;
     Eterm* hp;

     get_time(&hour, &minute, &second);
     hp = HAlloc(BIF_P, 4);	/* {hour, minute, second}  + arity */
     BIF_RET(TUPLE3(hp, make_small(hour), make_small(minute),
		    make_small(second)));
}

返回当前时,分,秒时间。时区和夏令时的时间调整取决于底层的操作系统。

erlang:time().