Jeffrey Kohn - Developer, Cook, Geek

  • Home
  • About Me
  • Blog
    • Sunday Dinners
    • Bacon
    • Beer
  • Recipes
    • Bacon
    • All Recipes
  • Code
  • Photos
  • Contact
Home

Recent Blog Posts

  • Boddingtons
  • Sunday Dinner - April 8, 2012
  • Sunday Dinner - Feb 26, 2012
  • HopCity Happy Hour Premium Ale
  • Coins
  • La Trappe - Quadrupel trappist ale
  • Sunday Dinner - Super Bowl
  • Top 5 pictures from my Flickr profile
  • Lunch?
  • Sunday Dinner - Oct 2
more

Recent Recipes

  • Bacon Whiskey Sour
  • Bacon Whiskey
  • Steak & mushroom pie
  • Oven Roasted Pulled Pork Sandwiches
  • Banana Rum Egg Nog
  • bacon wrapped poutine stuffed chicken
  • Ultimate Ice Cream Sandwich
  • Gambas al Ajillo (Garlic Shrimp)
  • Sufganiyot 2
  • Candied Bacon, Maple Whipped Cream Donuts
more

Javascript equivalent for PHP's microtime

Aug
21
2009

I was doing some javascript dev and needed php's microtime function. I did find some on the Internet but they weren't giving the right results so i wrote my own

// http://jeffrey-kohn.com/code
//
Javascript equivalent for PHP's microtime
function microtime(get_as_float)
{
    var unixtime_ms = new Date().getTime();
    var sec = parseInt(unixtime_ms / 1000);
   
    return get_as_float ? (unixtime_ms/1000) : (unixtime_ms - (sec * 1000))/1000 + ' ' + sec;
}

  • javascript
  • php
  • Add new comment

Twitter
Facebook
Flickr

  • home
  • about me
  • blog
  • recipes
  • code
  • photos
  • contact