Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Time

Status
Not open for further replies.

ITSmwong

Programmer
Aug 28, 2002
5
CA
Hello,

I have a table with a column that has the time stored by using the time() function. Now I need to convert it from military time to civilian time.

Thanks in advanced

Mike
 
Func AMPM(cTime) && cTime passed as string.
IF VAL(CTIME) < 12
CTIME = CTIME + " A.M"
ELSE
CTIME = STR(VAL(CTIME)-12,2)+SUBSTR(CTIME,3)+ " P.M"
ENDIF
RETURN (CTIME)


Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
Here's another way this can be accomplished...
Code:
?ConvertTime(TIME())

FUNCTION ConvertTime(tcMilitaryTime)
	LOCAL lcHoursWas, lcCivilianTime
	lcHoursWas = SET("hours")
	SET HOURS TO 12
	lcCivilianTime = TTOC(CTOT(DTOC(DATE()) + " " + tcMilitaryTime),2)
	SET HOURS TO &lcHoursWas
	RETURN lcCivilianTime
ENDFUNC

boyd.gif

SweetPotato Software Website
My Blog
 

This is interesting. I've never heard the expression "civilian time" to mean a 12-hour format. Is this an American usage?

Most of us use the 24-hour clock (what Americans call military time?) for things like train timetables or TV schedules, and the 12-hour system for normal day-to-day use.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 

Pamela, Dave,

We don't use 24-hour clock for anything outside the military over here

Now you mention it, I recall seeing airline schedules in the US with the 12-hour clock, with PM times in bold. I find it confusing, but then I guess that would be the same for you when you travel overseas.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top