Announcement

Collapse
No announcement yet.

24 hour to 12 am/pm trouble

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 24 hour to 12 am/pm trouble

    I'm puzzled by this.

    If have a time field hh:mm on my form. It's entered by the date-time picker in 24 hr format and I need to translate this to 12 hr format

    $dt= {mEvent_time_t};
    echo $dt;
    //$dt='22:33';
    $dx=date('h:i a', strtotime("$dt"));
    echo $dx;

    As it shows no matter what I enter, it will reply 6:00 pm
    Of course if I set $dt='22:33' then it will reply the correct time 11:33 am

    Now on some screens it works well, on some it doesn't. I've been spending ages on this and I simply cannot see what I'm doing wrong....
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

  • #2
    Ok, some more investigation. I'm using SQL Server. Despite the fact that I have set the time format to hhmm it still return hh:mm:ss:nnn format which cannot be converted. I used substr to get the hh:mm part. And if you look at the sql type it is emtpy so it looks like SC is not reading the datatype ok?
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      You should be able to use CAST for it?
      http://www.karaszi.com/sqlserver/info_datetime.asp
      datetime in SQL Server is a bit of an annoyance. Hence I prefer to use it as a string...

      Comment


      • #4
        The trick is to substring the time into the hh:mm format and then process. But actually, if you have defined the field as hh:mm Scriptcase should take care of this, no matter what database is used. For me, I consider this as a bug, although you can solve the issue by some code in the onload or onrecord event(s)
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          Working with date and time fields was always tricky. Glad you got it resolved.
          Originally posted by aducom View Post
          The trick is to substring the time into the hh:mm format and then process. But actually, if you have defined the field as hh:mm Scriptcase should take care of this, no matter what database is used. For me, I consider this as a bug, although you can solve the issue by some code in the onload or onrecord event(s)

          Comment

          Working...
          X