Time read from phone randomly switches between 24-hour and 12-hour time (AI1)

32 views
Skip to first unread message

GavinGT

unread,
Dec 15, 2015, 5:09:19 AM12/15/15
to MIT App Inventor Forum
My app uses the blocks Clock1.FormatTime>Clock1.Now to fetch the current time of day from the phone. However, when a user has his phone set to 24-hour time (on some devices running 5.1.1) the time that gets fetched randomly alternates between the 24-hour representation and the 12-hour representation. So one instant it might report 8:34, and then the next it will report 20:34. 

I'm on App Inventor Classic here. Anyone else experience this or know what to do about it?

Ghica

unread,
Dec 15, 2015, 7:14:46 AM12/15/15
to MIT App Inventor Forum
Switch to AI2! There is a conversion tool that works mostly fine.

GavinGT

unread,
Dec 15, 2015, 12:04:44 PM12/15/15
to MIT App Inventor Forum
The only problem is my app is gigantic. Lots of it doesn't convert correctly, plus AI2 isn't as good with large projects. Also, I don't know if the Play store would even accept the APK.

Taifun

unread,
Dec 15, 2015, 2:13:51 PM12/15/15
to MIT App Inventor Forum
App Inventor Classic has been shut down in July 2015. Your only possibility to continue is to convert the project into App Inventor 2, see also http://appinventor.mit.edu/explore/classic.html

Also follow these recommendations

Taifun

GavinGT

unread,
Dec 15, 2015, 11:20:30 PM12/15/15
to MIT App Inventor Forum
I'm using AILiveComplete v1.34, which enables me to continue using AI classic.

Italo

unread,
Dec 16, 2015, 12:35:40 AM12/16/15
to MIT App Inventor Forum
So I guess there's no way to fetch AM or PM from instant? 

GavinGT

unread,
Dec 17, 2015, 8:34:27 PM12/17/15
to MIT App Inventor Forum
My solution for this is to concatenate Clock1.Hour_Clock1.Now with Clock1.Minute_Clock1.Now, and adding a 0 if minutes are less than 10. This always provides a 24-hour result that is immune to the random switching, so then I just provide an option within the app to switch between 12-hour time and 24-hour time.
Reply all
Reply to author
Forward
0 new messages