且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用AngularJS / jQuery将24小时时间变量转换为12小时时间

更新时间:2023-02-26 16:16:07

你需要将值拆分,在通过模运算符运行第一个值后重建它。试试这个:

You need to split the value by :, the rebuild it after running the first value through the modulo operator. Try this:

var offTime = "17:25:11".split(':');
offTime[0] = offTime[0] % 12;
var output = offTime.join(':');

alert(output);