# Android QuestionTime format

#### Beja

##### Expert
Longtime User
Hello all
For a purpose I want to act on change in seconds from 00 to 59 .. Hours and minutes are ignored. This means
11:12:16 equals 10:35:16
Any idea?

#### emexes

##### Expert
DateTime.GetSeconds should do the trick.

I was going to say: watch out for changes at the start and end of daylight savings... but you should be ok because I believe all adjustments are a whole number of minutes (usually one hour).

Depending on your application, you might have to watch out for the leap second that happens every few years. Although leap seconds are added, not skipped, and thus the worst that might happen is that you launch your rockets (or whatever it is you're doing) twice instead of once.

You could calculate it from DateTime.Now, by dividing by 1000 (convert ms to s) and then modulus 60 (to "wrap it around" within 0..59), eg:
B4X:
``SecondOfMinute = (DateTime.Now / 1000) Mod 60``

#### Beja

##### Expert
Longtime User
DateTime.GetSeconds should do the trick.

I was going to say: watch out for changes at the start and end of daylight savings... but you should be ok because I believe all adjustments are a whole number of minutes (usually one hour).

Depending on your application, you might have to watch out for the leap second that happens every few years. Although leap seconds are added, not skipped, and thus the worst that might happen is that you launch your rockets (or whatever it is you're doing) twice instead of once.

You could calculate it from DateTime.Now, by dividing by 1000 (convert ms to s) and then modulus 60 (to "wrap it around" within 0..59), eg:
B4X:
``SecondOfMinute = (DateTime.Now / 1000) Mod 60``

Thanks emexes.
Will try that out.

Replies
3
Views
3K
Replies
22
Views
118K
Android Question TimeFormat Global?
Replies
3
Views
1K
Android Question Formatted military time
Replies
2
Views
953
Replies
111
Views
170K