# Current time in milliseconds ( javascript / cpp)?

**URL:** https://community.haxe.org/t/current-time-in-milliseconds-javascript-cpp/868
**Category:** Haxe
**Created:** [July 10, 2018, 11:07am UTC](https://community.haxe.org/t/current-time-in-milliseconds-javascript-cpp/868 "2018-07-10T11:07:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![flashultra](https://community.haxe.org/user_avatar/community.haxe.org/flashultra/32/82_2.png) [@flashultra](https://community.haxe.org/u/flashultra)
#### Post date: [July 10, 2018, 11:07am UTC](https://community.haxe.org/t/current-time-in-milliseconds-javascript-cpp/868/1 "2018-07-10T11:07:57Z")

</div>

What is the correct way to get time in milliseconds in Haxe ( for javascript / cpp platform) ?  
I think Sys.time() \* 1000 is more appropriate ( because is more accurate and can be compiled to cpp ) , but Sys.time is not supported for javascritpt ( HTML5) .  
From other side Date.now().getTime() will return per-second precision ( depends of target) .  
Why Haxe not have one function which can return milliseconds for all targets ?

---

<div class="post-metadata">

### Author: ![dmitryhryppa](https://community.haxe.org/user_avatar/community.haxe.org/dmitryhryppa/32/1815_2.png) [@dmitryhryppa](https://community.haxe.org/u/dmitryhryppa)
#### Post date: [July 10, 2018, 12:14pm UTC](https://community.haxe.org/t/current-time-in-milliseconds-javascript-cpp/868/2 "2018-07-10T12:14:46Z")

</div>

Try this: [haxe.Timer - Haxe 4.2.1 API](https://api.haxe.org/haxe/Timer.html#stamp)  
It should work on all targets.

`haxe.Timer.stamp()` returns time in seconds, but with fraction (1531224658.135 for example), so you can multiply it by 1000 and get accurate milliseconds.
