• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1856
  • Last Modified:

Milliseconds time format in My SQL

Can any one help.
How do you configure a table field for milliseconds in MySQL?

eg. HH:MM:SS:AAA

AAA=milliseconds

I want to create a database that holds lap records for games.

Please help me.

PBUK.
0
PBUK
Asked:
PBUK
  • 2
1 Solution
 
VGRCommented:
you CAN'T

use a varchar field, they are asisgnation-compatible with TIMESTAMPS and DATE/TIME

http://www.mysql.com/doc/en/Date_and_time_functions.html
0
 
VGRCommented:
in the case this is useful to you, this computes delta times in milliseconds :

<?
//VGR14042001 Creation
//VGR24112002 ADDed sécurité pour mode globDisc
//

//
// ----------------------------- FORUM -----------------------------------
//
function myTime() { // en secondes
$loc1=microtime();
$loc2 = (double)substr (strrchr ($loc1, ' '), 1); // secondes entières
$loc3 = (double)substr ($loc1, 1,strpos($loc1,' ')); // fraction de seconde = 0.xxx
$loc2 = $loc2+$loc3;
//test
//echo "time $loc1 -> $loc2<BR>";
//
return $loc2;
}

function TimerStart() {
  GLOBAL $TTime;
  $TTime=myTime();
} // TimerStart Procedure

function TimerStop($parDisp=FALSE) { // and display
  GLOBAL $TTime;
  $locTime=myTime()-$TTime; // en secondes
  //VGR14042001 BUGFIX
  // il y a un bug dans la fonction de base : la seconde n'est pas incrémentée correctement.
  if ($locTime<0) $locTime=1.0+$locTime;
  //EoFIX
  $locTime=round(1000.0*$locTime,5); // millisecondes arrondies à la 5ème décimale
  if ($parDisp) echo "<BR><CENTER><font size=-2>page generated in $locTime milliseconds</font></CENTER>";
  return($locTime);
} // TimerStop Integer (ms) Function
?>
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now