• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ArmyTime

Participant ,
Jun 22, 2006 Jun 22, 2006

Copy link to clipboard

Copied

I have this time in an <input type"text" name="Atime"> is shows like this 13:00 is army time....What i want to do is

<cfif Atime GT 12>
<cfset Atime = Atime & Right(Evaluate("Atime"), 5) & "PM">
</cfif>

I know i have to reference the hours some how but thats where i get lost any help would be great....but basiscally if the hour is greater than 12 i want to add PM to it
TOPICS
Advanced techniques

Views

275

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2006 Jun 22, 2006

Copy link to clipboard

Copied

I do not completely understanding your requirement. If you where to use
dateTime objects you can convert between 12 hour and 24 hour time
displays at will.

But to take a crack at your logic.

<cfif ListFirst(Form.Atime,":") GT 12>
<cfset form.Atime = form.Atime & " PM">
</cfif>

This should result in output like "13:00 PM". Is that what you want?

PackinDaMAC wrote:
> I have this time in an <input type"text" name="Atime"> is shows like this 13:00
> is army time....What i want to do is
>
> <cfif Atime GT 12>
> <cfset Atime = Atime & Right(Evaluate("Atime"), 5) & "PM">
> </cfif>
>
> I know i have to reference the hours some how but thats where i get lost any
> help would be great....but basiscally if the hour is greater than 12 i want to
> add PM to it
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 22, 2006 Jun 22, 2006

Copy link to clipboard

Copied

You can get the hour part of a time by using the Hour() function. Same goes for Minute() and Second()

<CFIF IsDefined("Atime")>
<CFIF Hour(Atime) GT 12>
<CFSET Atime=TimeFormat(Atime, "h:mm ") & "PM">
</CFIF>
</CFIF>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2006 Jun 22, 2006

Copy link to clipboard

Copied

Only if you have previously converted the form string into a time
object. Otherwise you are using string manipulation.

Jay-son wrote:
> You can get the hour part of a time by using the Hour() function. Same goes for
> Minute() and Second()
>
> <CFIF IsDefined("Atime")>
> <CFIF Hour(Atime) GT 12>
> <CFSET Atime=TimeFormat(Atime, "h:mm ") & "PM">
> </CFIF>
> </CFIF>
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 22, 2006 Jun 22, 2006

Copy link to clipboard

Copied

LATEST
I used the Mid() function and got it exactly how i needed it...Thanks people!!!!

<cfif Mid(str, 15, 3) GT 12>
<cfset str = str & Right(Evaluate("dateseen#i#"), 5) & ", PM , ">
<cfset str = str & Left(Evaluate("dateseen#i#"), 10) & " , ">
<cfelseif Mid(str, 15, 3) LT 12>
<cfset str = str & Right(Evaluate("dateseen#i#"), 5) & ", AM , ">
<cfset str = str & Left(Evaluate("dateseen#i#"), 10) & " , ">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation