4 Replies Latest reply on Jun 22, 2006 12:58 PM by PackinDaMAC

    ArmyTime

    PackinDaMAC Level 1
      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
        • 1. Re: ArmyTime
          Level 7
          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
          >
          • 2. Re: ArmyTime
            Jay-son Level 1
            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>
            • 3. Re: ArmyTime
              Level 7
              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>
              >
              • 4. Re: ArmyTime
                PackinDaMAC Level 1
                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) & " , ">