Page 1 of 1

I need a Time function to display Am/Pm

Posted: Sat Jul 27, 2013 7:43 am
by unixkd
Hi all
I need a Time function to display Am/Pm format

Thanks.

Joe

Re: I need a Time function to display Am/Pm

Posted: Sat Jul 27, 2013 11:15 am
by bwolfsohn
************
function cusampm(timestring)
************
local minutes,hours,suffix,char_min
hours :=val(subs(timestring,1,2))
minutes:=val(subs(timestring,4,2))
minutes:=hours*60+minutes
hours:=minutes/60
suffix:=if(hours<12,'am','pm')
if hours>12
hours:=hours-12
endif
if hours<1
hours:=12+hours
endif
char_min:=str(60*(hours-int(hours)),2,0)
return( str(int(hours),2,0)+':'+IF(char_min=' ','0'+SUBS(char_min,2,1),char_min)+suffix )

Re: I need a Time function to display Am/Pm

Posted: Sat Jul 27, 2013 12:42 pm
by unixkd
Thanks,

Work well for me.

Joe