How to put system time into hh:mm:ss [SOLVED]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

How to put system time into hh:mm:ss [SOLVED]

Post by morrell » Thu Jan 01, 2015 12:20 pm

How can I get the system time to display in 24 hours with hh:mm:ss which at the moment my

Code: Select all

put the system time into field "SThhmmss"
is not giving me what I want.

Example:-
I need 3 am. to display as 03:00:00 and 3 pm. to display as 15:00:00

Regards,

Ruth
Last edited by morrell on Fri Jan 02, 2015 9:35 am, edited 3 times in total.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: How to put system time into hh:mm:ss

Post by Dixie » Thu Jan 01, 2015 12:26 pm

Code: Select all

on mouseUp
   set the twelvehourTime to false
   put the long time
end mouseUp

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to put system time into hh:mm:ss

Post by morrell » Thu Jan 01, 2015 1:43 pm

Thank you Dixie.

After adding your code to mine:-

Code: Select all

on mouseUp
set the twelvehourTime to false
put the long time
put the system time into field "SThhmmss"
end mouseUp
Whilst my field does now show the hh:mm:ss as I wanted, I now have a message box appear which I don't want. What do I add or change for no message box to appear?

Regards,

Ruth

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: How to put system time into hh:mm:ss

Post by Dixie » Thu Jan 01, 2015 2:46 pm

Ruth..

try

Code: Select all

   on mouseUp
    set the twelvehourTime to false
    put the long time into field "SThhmmss"
    --put the system time into field "SThhmmss"
    end mouseUp

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to put system time into hh:mm:ss

Post by morrell » Thu Jan 01, 2015 3:11 pm

That corrected it Dixie and many thanks.

Regards,

Ruth
Last edited by morrell on Fri Jan 02, 2015 2:11 am, edited 1 time in total.

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to put system time into hh:mm:ss

Post by morrell » Fri Jan 02, 2015 2:10 am

When I said it was corrected in my previous answer we were on PM time and unfortunately when midnight passed it then displayed as h:mm:ss and not hh:mm:ss

Regards,

Ruth

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: How to put system time into hh:mm:ss

Post by dunbarx » Fri Jan 02, 2015 2:37 am

Ruth.

Can you write the couple of lines of code that pad the hours portion of the time with a "0" if it needs one? In other words, can you make "1" into "01"? Do you know about the itemDelimiter, and how it might be used for this?

Craig Newman

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: How to put system time into hh:mm:ss

Post by Dixie » Fri Jan 02, 2015 7:51 am

Hi Ruth...

This will correct it...:-)

Code: Select all

on mouseUp
   set the twelvehourTime to false
   put the long time into tempTime
   
   if the number of chars of tempTime = 7 then
      put 0 & tempTime into tempTime
   end if
   
   put tempTime into fld "SThhmmss"
end mouseUp

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to put system time into hh:mm:ss [SOLVED]

Post by morrell » Fri Jan 02, 2015 9:28 am

Thank you dunbarx and Dixie.

Regards,

Ruth

Post Reply