Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang and current date time

Tags:

time

erlang

I would like to get a current date time with erlang. I have tried using the code below;

{{Year,Month,Day},{Hour,Min,Sec}} = erlang:localtime().

But sometimes it got an error like '** exception error: no match of right hand side value {{2012,5,6},{23,40,58}}'

Looks like there is a problem with 1 digit. I try searching couple of webs but still cannot find a way to cope this.

I believe this is quite an easy one but as a erlang newbie, I cannot resolve this. I try my best.

Env: Erlang {"OTP APN 181 01","R15B01"} installed with windows binary version Windows XP

Thanks in advance,

like image 242
large Avatar asked May 06 '12 16:05

large


1 Answers

No, there is no problem with 1 digit. It should match perfectly well (check with {{Year,Month,Day},{Hour,Min,Sec}} = {{2012,5,6},{23,40,58}}). Most likely you have already assigned one of the variables to something earlier in the function.

like image 61
Alexey Romanov Avatar answered Oct 01 '22 14:10

Alexey Romanov