manuelBetancurt
manuelBetancurt

Reputation: 16158

ios date picker to unix timestamp

I have a date from a date picker, I need to make it a unix timestamp, I log it but get a wrong value,

here my code:

time_t unixTime = (time_t) [self.datePicker.date timeIntervalSince1970];

    NSLog(@"el timestamp:: %lo", unixTime);

this is the log

2012-06-01 22:13:18.543 ClientApp[50494:12503] escojio ::2012-06-01 12:12:16 +0000
2012-06-01 22:14:13.163 ClientApp[50494:12503] el timestamp:: 11762137660

I go to a timestamp calculator and get a completely wrong time, do i have to format it in some way?,

so what im I doing wrong?

thanks!

Upvotes: 0

Views: 1465

Answers (1)

Ole Begemann
Ole Begemann

Reputation: 135548

The %lo format specifier outputs a number in octal notation. Are you sure you compared it to a Unix timestamp with the same notation?

11762137660(oct) == 1338556336(dec), which sounds about right for today.

Upvotes: 3

Related Questions