ericjgagnon / wickedpicker

A simple jQuery timepicker
http://ericjgagnon.github.io/wickedpicker/
MIT License
93 stars 78 forks source link

Setting 24 hour format in options caused picker to show NaN:NaN #49

Closed springcode closed 6 years ago

springcode commented 7 years ago

I have temporarily fixed this by checking the format in the showPicker: method (line 113) and not using the regex when splitting if it is in 24 hour format. This works ok for me but is just a sticking plaster as it may affect other functionality?

            var inputTime;
            if (this.twentyFour == false)
                inputTime = text.replace(/\s\w\w$/, '').split(this.options.timeSeparator);
            else
                inputTime = text.split(this.options.timeSeparator);
fnipo commented 7 years ago

I had to set the 'timeSeparator' property in order to make it work.

$('.timepicker-24-hr').wickedpicker({ twentyFour: true, timeSeparator: ':' });

fabirovskyy commented 7 years ago

original : ---» timeSeparator: ' : ', // The string to put in between hours and minutes (and seconds) change to : --» timeSeparator: ':', // The string to put in between hours and minutes (and seconds)

abdoroot commented 6 years ago

i face the same problem me be i will change to another time picker or i have to edit the date before save and save it into 24 hours

abdoroot commented 6 years ago

i make this php function to solve 24 hours problem

function date24($date){
    $sDate = explode(" ",$date);
    if($sDate['3']  == "AM"){
        return $sDate['0'].":".$sDate['2'];
    }else if($sDate['3']  == "PM"){
        return ($sDate['0'] + 12).":".$sDate['2'];
    }
}

hope this help some one