-3

I have integer milliseconds like 619308. How can I parse it to format HH:MM:SS:UU by using Javascript or PHP ???

Sorry for my bad English

DucPT
  • 41
  • 1
  • 6

2 Answers2

0

Your number is pretty small for milliseconds but...

Try this:

<?php

function formatp($input)
{
  $hours = (int)($minutes = (int)($seconds = (int)($milliseconds = (int)($input * 1000)) / 1000) / 60) / 60;
  return $hours.':'.($minutes%60).':'.($seconds%60).(($milliseconds===0)?'':'.'.rtrim($milliseconds%1000, '0'));
}

echo formatp(4.2225662134);

Credits

imbondbaby
  • 6,351
  • 3
  • 21
  • 54
0

Use Date()

var d = new Date( 619308 );
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1;
var curr_year = d.getFullYear();

user3771955
  • 3
  • 1
  • 5