0

Can someone suggest me how I can convert a variable that contain time in millisec to an exact date? The code is below:

long long SenderTimestamp=System::currentTimeMillis();

obviously the time in millisec is in the variable SenderTimestamp

Thanks

CecchinoSMI
  • 169
  • 13

1 Answers1

1

In your case this is simpler :

int seconds = (int) (milliseconds / 1000) % 60 ;
int minutes = (int) ((milliseconds / (1000*60)) % 60);
int hours   = (int) ((milliseconds / (1000*60*60)) % 24);
Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
  • Ok but...I need more clarity.... milliseconds means my variable? and how I can set these three values (seconds, minutes, hours) in a single variable? – CecchinoSMI Jan 08 '14 at 10:53
  • 1
    +1, but I think it is better to use `static_cast` instead, since the question is tagged `C++`, see: http://stackoverflow.com/questions/103512/in-c-why-use-static-castintx-instead-of-intx – Moha the almighty camel Jan 08 '14 at 10:55