9 Replies Latest reply on Aug 6, 2008 4:24 PM by mohnkhan

    unhiding/formatting 00 in minutes and hours

    Simon TL
      I am showing times using an ADT dynamic form. A time such as 09:00 is shown as 9 ie without the zero minutes. Or midnight ie 00:00 will be hidden completely. Where can I zap the code to stop this happening. Thanks...
        • 1. Re: unhiding/formatting 00 in minutes and hours
          Level 1
          Simon,

          Please explain in more detail about what you are doing. Where/How are you showing these times?

          Shane
          • 2. Re: unhiding/formatting 00 in minutes and hours
            Simon TL Level 1
            Shane

            DW CS3, with Adobe Developer Toolkit, in add/edit/delete form, I have a field from MySQL database (date/time). I use the ADT Control Panel to make the date the European format. All is fine *except* that a zero minutes field will show as, for example 8 rather than 8:00, and midnight was be completely blank rather than 00:00. Something somewhere is saying if minutes are zero don't show it.

            Thanks
            • 3. Re: unhiding/formatting 00 in minutes and hours
              Level 1
              Simon,

              I have never had to use the European format, so I've never had this issue. When you say "show as", are you refering to the date picker display on the form page? Does the date insert correctly into the database?

              Shane
              • 4. Re: unhiding/formatting 00 in minutes and hours
                Simon TL Level 1
                Shane

                By 'show' I simply mean in the date/time field (not the date picker).

                So '2008-09-04 09:00:00' from the database table could be formatted and show as:

                04/09/2008 09

                whereas I want to see:

                04/09/2008 09:00

                On the other hand, '2008-09-04 09:30:00' will show correctly as:

                04/09/2008 09:30

                SO the problem is there is code somewhere which says "The minutes are zero so I won't show ':00', I'll just go and lose it."

                Equally, '2008-09-04 00:00:00' will show as:

                04/09/2008

                - with NO time, whereas I want to see:

                04/09/2008 00:00
                • 5. Re: unhiding/formatting 00 in minutes and hours
                  mohnkhan Level 1
                  Hello,
                  I am not a php guy, but i would recommend this..
                  1. Also is it storing the date correctly in database ?
                  2. whats ur current date format in ADDT control panel?

                  if its only a cosmetic viewing issue then
                  go to
                  includes\common\kt_functions.inc.asp <-- for asp for php it should be php file..

                  Function KT_formatDate(date__param)
                  If Not KT_isSet(date__param) Then
                  KT_formatDate = ""
                  Exit Function
                  End If
                  KT_formatDate = KT_convertDateCall(date__param, "toscreen")
                  End Function

                  this function calls..

                  "Function KT_convertDateCall(date__param, toScreen)"
                  this is a horrible hacked function... which uses regular expressions to clean up mess or create more of a mess.

                  if ur application is always gonna use that same time format ..
                  then u can write one more wrapper function..
                  over KT_formatDate which would check if there is no time.. them simply appends that colon ZERO ZERO to the time as text string.

                  just an idea..

                  hope it helps...
                  mohnkhan
                  • 6. Re: unhiding/formatting 00 in minutes and hours
                    mohnkhan Level 1
                    for php
                    includes\common\kt_functions.inc.php

                    line 1502.
                    function KT_formatDate($date) {
                    return KT_convertDateCall($date, 'toscreen');
                    }

                    i would write a new wrapper to this function..
                    line 1415
                    KT_convertDateCall($date, 'toscreen');

                    here in this function...

                    I tried doing this...

                    /* if ($toScreen == 'toscreen') {
                    $date = KT_stripTime($date);

                    }*/

                    line 1462...

                    i commented the strip time function call..
                    and now it works fine with zero dates..

                    i havent throughly bug tested it..

                    but it worked for me..
                    if u still have problems report to me..

                    bcos i just build one php page to test it for you...

                    hope this helps..

                    thanks.. for reading long boring post..
                    mohnkhan
                    http://www.mohitech.com
                    • 7. Re: unhiding/formatting 00 in minutes and hours
                      mohnkhan Level 1
                      Hi,
                      Line no 1416
                      for php
                      includes\common\kt_functions.inc.php

                      the exact function that does this is.. here..
                      /**
                      * Strips empty values from time expressions
                      * @param string $date - datetime expression
                      * @return new datetime without 0's
                      */
                      function KT_stripTime($date) {
                      if ( strstr($date, ' ') && strstr($date, ':') && (strpos($date, ' ') < strpos($date, ':')) ) {
                      $dateArr = explode(' ', $date);
                      $timeArr = explode(':', $dateArr[1]);
                      for ($i = count($timeArr) - 1; $i >=0; $i--) {
                      if ($timeArr[$i] != '0' && $timeArr[$i] != '00') {
                      break;
                      } else {
                      unset($timeArr[$i]);
                      }
                      }
                      // remove time when [time format is hh:mm:ss tt] and [time value is 12 A(M)]
                      if ( count($timeArr) == 1 && trim($timeArr[0]) == '12' && count($dateArr) == 3 && (strtolower(trim($dateArr[2])) == 'a' || strtolower(trim($dateArr[2])) == 'am') ) {
                      unset($timeArr[0]);
                      unset($dateArr[2]);
                      }
                      $dateArr[1] = implode(':', $timeArr);
                      if ($dateArr[1] == '') {
                      unset($dateArr[1]);
                      }
                      $date = implode(' ', $dateArr);
                      }
                      return $date;
                      }
                      • 8. Re: unhiding/formatting 00 in minutes and hours
                        Simon TL Level 1
                        Hi and thanks...

                        You're a STAR!

                        Indeed....

                        if ($toScreen == 'toscreen') {
                        //$date = KT_stripTime($date);
                        }

                        ...lines 1462-1464 ...works fine. Thanks again.
                        • 9. Re: unhiding/formatting 00 in minutes and hours
                          mohnkhan Level 1
                          Hi Simon TLewis,

                          you are most welcome ..

                          Cheers

                          mohnkhan