<<MenuNavi(rosserial/Overview)>> <<TableOfContents(4)>> == Time and Duration == ROS has builtin `time` and `duration` primitive types, which [[rosserial]] provides as the `ros::Time` and `ros::Duration` classes, respectively. A `Time` is a specific moment (e.g. "today at 5pm") whereas a `Duration` is a period of time (e.g. "5 hours"). Durations can be negative. Times and durations have identical representations: {{{ unsigned long secs unsigned long nsecs }}} === Getting the Current Time === In order to get the current ROS time, you must be connected to ROS. Then, you can use your !NodeHandle object, `nh`, to query the current time. `nh.now()` Get the current time as a `ros::Time` instance: {{{ #!cplusplus ros::Time begin = nh.now(); }}} === Creating Time and Duration Instances === You can create a `Time` or `Duration` to a specific value as well, either using a two-integer constructor: {{{ #!cplusplus ros::Time a_little_after_the_beginning(0, 10000); ros::Duration five_seconds(5, 0); }}} === Converting Time and Duration Instances === `Time` and `Duration` objects can also be turned into floating point seconds: {{{ #!cplusplus double secs = nh.now().toSec(); ros::Duration d(1, 0); secs = d.toSec(); }}}