Converts minutes into HH:MM format - Node.js Date

Node.js examples for Date:Date Format

Description

Converts minutes into HH:MM format

Demo Code


/*//  w w w .j  a v  a 2  s  .com
 * This file is part of YoHours.
 * 
 * YoHours is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * YoHours is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with YoHours.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * YoHours
 * Web interface to make opening hours data for OpenStreetMap the easy way
 * Author: Adrien PAVIE
 *
 * Utility JS methods
 */

/**
 * Converts minutes into HH:MM format
 * @param m The amount of minutes
 */
function minToHourMin(m) {
  var hours = Math.floor(m/60);
  if(hours < 10) { hours = "0"+hours; }
  var minutes = m % 60;
  if(minutes < 10) { minutes = "0"+minutes; }
  return hours+":"+minutes;
};

Related Tutorials