diff --git a/src/data.hpp b/src/data.hpp
index 5130b03..9fd00ab 100644
--- a/src/data.hpp
+++ b/src/data.hpp
@@ -18,18 +18,18 @@
 #include "management/nfd-local-control-header.hpp"
 
 namespace ndn {
-  
+
 class Data : public enable_shared_from_this<Data>
 {
 public:
   struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
-  
+
   /**
    * @brief Create an empty Data object
    */
   inline
   Data();
-  
+
   /**
    * @brief Create a new Data object with the given name
    * @param name A reference to the name which is copied.
@@ -45,20 +45,20 @@
   {
     wireDecode(wire);
   }
-  
+
   /**
    * @brief The destructor
    */
   inline
   ~Data();
-  
+
   /**
    * @brief Fast encoding or block size estimation
    */
   template<bool T>
   inline size_t
   wireEncode(EncodingImpl<T> &block, bool unsignedPortion = false) const;
-  
+
   /**
    * @brief Encode to a wire format
    */
@@ -68,7 +68,7 @@
   /**
    * @brief Decode from the wire format
    */
-  inline void 
+  inline void
   wireDecode(const Block &wire);
 
   /**
@@ -76,12 +76,12 @@
    */
   inline bool
   hasWire() const;
-  
-  ////////////////////////////////////////////////////////////////////  
-  
-  inline const Name& 
+
+  ////////////////////////////////////////////////////////////////////
+
+  inline const Name&
   getName() const;
-  
+
   /**
    * @brief Set name to a copy of the given Name.
    *
@@ -92,10 +92,10 @@
   setName(const Name& name);
 
   //
-  
-  inline const MetaInfo& 
+
+  inline const MetaInfo&
   getMetaInfo() const;
-  
+
   /**
    * @brief Set metaInfo to a copy of the given MetaInfo.
    * @param metaInfo The MetaInfo which is copied.
@@ -105,25 +105,25 @@
   setMetaInfo(const MetaInfo& metaInfo);
 
   //
-  
+
   ///////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////
   // MetaInfo proxy methods
 
-  inline uint32_t 
+  inline uint32_t
   getContentType() const;
-  
-  inline void 
+
+  inline void
   setContentType(uint32_t type);
 
   //
-  
-  inline Milliseconds 
+
+  inline const time::milliseconds&
   getFreshnessPeriod() const;
-  
-  inline void 
-  setFreshnessPeriod(Milliseconds freshnessPeriod);
+
+  inline void
+  setFreshnessPeriod(const time::milliseconds& freshnessPeriod);
 
   //
 
@@ -137,14 +137,14 @@
   ///////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////
-  
+
   /**
    * @brief Get content Block
    *
    * To access content value, one can use value()/value_size() or
    * value_begin()/value_end() methods of the Block class
    */
-  inline const Block& 
+  inline const Block&
   getContent() const;
 
   /**
@@ -162,17 +162,17 @@
   setContent(const ConstBufferPtr &contentValue);
 
   //
-  
+
   inline const Signature&
   getSignature() const;
-  
+
   /**
    * @brief Set the signature to a copy of the given signature.
    * @param signature The signature object which is cloned.
    */
   inline void
   setSignature(const Signature& signature);
-  
+
   inline void
   setSignatureValue(const Block &value);
 
@@ -183,18 +183,18 @@
 
   const nfd::LocalControlHeader&
   getLocalControlHeader() const;
-  
+
   inline uint64_t
   getIncomingFaceId() const;
 
   inline void
   setIncomingFaceId(uint64_t incomingFaceId);
-  
+
 private:
   /**
    * @brief Clear the wire encoding.
    */
-  inline void 
+  inline void
   onChanged();
 
 private:
@@ -253,10 +253,10 @@
 
   // SignatureInfo
   total_len += prependBlock(block, m_signature.getInfo());
-  
+
   // Content
   total_len += prependBlock(block, getContent());
-  
+
   // MetaInfo
   total_len += getMetaInfo().wireEncode(block);
 
@@ -279,16 +279,16 @@
 
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
-  
+
   EncodingBuffer buffer(estimatedSize, 0);
   wireEncode(buffer);
 
   const_cast<Data*>(this)->wireDecode(buffer.block());
   return m_wire;
 }
-  
+
 /**
- * Decode the input using a particular wire format and update this Data. 
+ * Decode the input using a particular wire format and update this Data.
  * @param input The input byte array to be decoded.
  */
 void
@@ -302,7 +302,7 @@
   //            MetaInfo
   //            Content
   //            Signature
-    
+
   // Name
   m_name.wireDecode(m_wire.get(Tlv::Name));
 
@@ -315,10 +315,10 @@
   ///////////////
   // Signature //
   ///////////////
-  
+
   // SignatureInfo
   m_signature.setInfo(m_wire.get(Tlv::SignatureInfo));
-  
+
   // SignatureValue
   Block::element_const_iterator val = m_wire.find(Tlv::SignatureValue);
   if (val != m_wire.elements_end())
@@ -331,53 +331,53 @@
   return m_wire.hasWire();
 }
 
-inline const Name& 
+inline const Name&
 Data::getName() const
 {
   return m_name;
 }
-  
+
 inline void
 Data::setName(const Name& name)
-{ 
+{
   onChanged();
-  m_name = name; 
+  m_name = name;
 }
-  
-inline const MetaInfo& 
+
+inline const MetaInfo&
 Data::getMetaInfo() const
 {
   return m_metaInfo;
 }
-  
+
 inline void
-Data::setMetaInfo(const MetaInfo& metaInfo) 
-{ 
+Data::setMetaInfo(const MetaInfo& metaInfo)
+{
   onChanged();
-  m_metaInfo = metaInfo; 
+  m_metaInfo = metaInfo;
 }
 
-inline uint32_t 
+inline uint32_t
 Data::getContentType() const
 {
   return m_metaInfo.getType();
 }
-  
-inline void 
+
+inline void
 Data::setContentType(uint32_t type)
 {
   onChanged();
   m_metaInfo.setType(type);
 }
-  
-inline Milliseconds 
+
+inline const time::milliseconds&
 Data::getFreshnessPeriod() const
 {
   return m_metaInfo.getFreshnessPeriod();
 }
-  
-inline void 
-Data::setFreshnessPeriod(Milliseconds freshnessPeriod)
+
+inline void
+Data::setFreshnessPeriod(const time::milliseconds& freshnessPeriod)
 {
   onChanged();
   m_metaInfo.setFreshnessPeriod(freshnessPeriod);
@@ -396,7 +396,7 @@
   m_metaInfo.setFinalBlockId(finalBlockId);
 }
 
-inline const Block& 
+inline const Block&
 Data::getContent() const
 {
   if (m_content.empty())
@@ -408,7 +408,7 @@
 }
 
 inline void
-Data::setContent(const uint8_t* content, size_t contentLength) 
+Data::setContent(const uint8_t* content, size_t contentLength)
 {
   onChanged();
 
@@ -422,9 +422,9 @@
 
   m_content = Block(Tlv::Content, contentValue); // not real a wire encoding yet
 }
-  
+
 inline void
-Data::setContent(const Block& content) 
+Data::setContent(const Block& content)
 {
   onChanged();
 
@@ -440,9 +440,9 @@
 {
   return m_signature;
 }
-  
+
 inline void
-Data::setSignature(const Signature& signature) 
+Data::setSignature(const Signature& signature)
 {
   onChanged();
   m_signature = signature;
@@ -482,14 +482,14 @@
   // ! do not reset Data's wire !
 }
 
-inline void 
+inline void
 Data::onChanged()
 {
   // The values have changed, so the wire format is invalidated
 
   // !!!Note!!! Signature is not invalidated and it is responsibility of
   // the application to do proper re-signing if necessary
-  
+
   m_wire.reset();
 }
 
diff --git a/src/detail/pending-interest.hpp b/src/detail/pending-interest.hpp
index b53dc1f..4cfc48a 100644
--- a/src/detail/pending-interest.hpp
+++ b/src/detail/pending-interest.hpp
@@ -30,15 +30,10 @@
     : interest_(interest),
       onData_(onData), onTimeout_(onTimeout)
   {
-    // Set up timeoutTime_.
-    if (interest_->getInterestLifetime() >= 0)
-      timeoutTimeMilliseconds_ = getNowMilliseconds() + interest_->getInterestLifetime();
+    if (interest_->getInterestLifetime() >= time::milliseconds::zero())
+      timeout_ = time::steady_clock::now() + interest_->getInterestLifetime();
     else
-      // No timeout.
-      /**
-       * @todo Set more meaningful default timeout.  This timeout MUST exist.
-       */
-      timeoutTimeMilliseconds_ = getNowMilliseconds() + 4000;
+      timeout_ = time::steady_clock::now() + DEFAULT_INTEREST_LIFETIME;
   }
     
   const shared_ptr<const Interest>& 
@@ -55,13 +50,12 @@
     
   /**
    * Check if this interest is timed out.
-   * @param nowMilliseconds The current time in milliseconds from getNowMilliseconds.
    * @return true if this interest timed out, otherwise false.
    */
   bool 
-  isTimedOut(MillisecondsSince1970 nowMilliseconds)
+  isTimedOut(const time::steady_clock::TimePoint& now)
   {
-    return timeoutTimeMilliseconds_ >= 0.0 && nowMilliseconds >= timeoutTimeMilliseconds_;
+    return now >= timeout_;
   }
 
   /**
@@ -80,8 +74,8 @@
   const OnData onData_;
   const OnTimeout onTimeout_;
 
-  /** The time when the interest times out in milliseconds according to getNowMilliseconds, or -1 for no timeout. */
-  MillisecondsSince1970 timeoutTimeMilliseconds_;
+  /** The time when the interest times out in time::milliseconds according to getNowMilliseconds, or -1 for no timeout. */
+  time::steady_clock::TimePoint timeout_;
 };
 
 
diff --git a/src/encoding/cryptopp/asn_ext.cpp b/src/encoding/cryptopp/asn_ext.cpp
index beea45d..7741314 100644
--- a/src/encoding/cryptopp/asn_ext.cpp
+++ b/src/encoding/cryptopp/asn_ext.cpp
@@ -17,29 +17,14 @@
 namespace ndn {
 
 size_t
-DEREncodeGeneralTime(CryptoPP::BufferedTransformation &bt, MillisecondsSince1970 time)
+DEREncodeGeneralTime(CryptoPP::BufferedTransformation &bt, const time::system_clock::TimePoint& time)
 {
-  if (time < 0)
-    throw Asn::Error("Calendar time value out of range");
-  else if (time > 2e14)
-    // 2e14 is about the year 8300.  We don't want to go over a 4-digit year.
-    throw Asn::Error("Calendar time value out of range");
+  std::string str = time::toIsoString(time);
+  // For example, 20131226T232254
+  // 20131226T232254.100000
+  BOOST_ASSERT(str.size() >= 15);
+  std::string asn1time = str.substr(0, 8) + str.substr(9,6) + "Z";
 
-
-  boost::posix_time::ptime boostTime =
-    UNIX_EPOCH_TIME + boost::posix_time::milliseconds(time);
-  
-  const boost::format f = boost::format("%04d%02d%02d%02d%02d%02dZ")
-                % boostTime.date().year_month_day().year
-                % boostTime.date().year_month_day().month.as_number()
-                % boostTime.date().year_month_day().day.as_number()
-                % boostTime.time_of_day().hours()
-                % boostTime.time_of_day().minutes()
-                % boostTime.time_of_day().seconds()
-    ;
-
-  std::string asn1time = f.str();
-  
   bt.Put(GENERALIZED_TIME);
   size_t lengthBytes = DERLengthEncode(bt, asn1time.size());
   bt.Put(reinterpret_cast<const uint8_t*>(asn1time.c_str()), asn1time.size());
@@ -47,7 +32,7 @@
 }
 
 void
-BERDecodeTime(CryptoPP::BufferedTransformation &bt, MillisecondsSince1970 &time)
+BERDecodeTime(CryptoPP::BufferedTransformation &bt, time::system_clock::TimePoint& time)
 {
   byte b;
   if (!bt.Get(b) || (b != GENERALIZED_TIME && b != UTC_TIME))
@@ -71,7 +56,7 @@
       str = "19" + str;
   }
  
-  time = fromIsoString(str.substr(0, 8) + "T" + str.substr(8, 6));
+  time = time::fromIsoString(str.substr(0, 8) + "T" + str.substr(8, 6));
 }
 
 } // namespace ndn
diff --git a/src/encoding/cryptopp/asn_ext.hpp b/src/encoding/cryptopp/asn_ext.hpp
index e0a9a6b..b02b3e9 100644
--- a/src/encoding/cryptopp/asn_ext.hpp
+++ b/src/encoding/cryptopp/asn_ext.hpp
@@ -16,14 +16,14 @@
 namespace ndn {
 
 namespace Asn {
-struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
+struct Error : public std::runtime_error { Error(const std::string& what) : std::runtime_error(what) {} };
 }
 
 size_t
-DEREncodeGeneralTime(CryptoPP::BufferedTransformation &bt, MillisecondsSince1970 time);
+DEREncodeGeneralTime(CryptoPP::BufferedTransformation& bt, const time::system_clock::TimePoint& time);
 
 void
-BERDecodeTime(CryptoPP::BufferedTransformation &bt, MillisecondsSince1970 &time);
+BERDecodeTime(CryptoPP::BufferedTransformation& bt, time::system_clock::TimePoint& time);
 
 } // namespace ndn
 
diff --git a/src/face.cpp b/src/face.cpp
index fe509c4..aec1cdf 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -65,8 +65,8 @@
   m_transport = transport;
   m_ioService = ioService;
 
-  m_pitTimeoutCheckTimer      = make_shared<boost::asio::deadline_timer>(boost::ref(*m_ioService));
-  m_processEventsTimeoutTimer = make_shared<boost::asio::deadline_timer>(boost::ref(*m_ioService));
+  m_pitTimeoutCheckTimer      = make_shared<monotonic_deadline_timer>(boost::ref(*m_ioService));
+  m_processEventsTimeoutTimer = make_shared<monotonic_deadline_timer>(boost::ref(*m_ioService));
 
   if (std::getenv("NFD") != 0)
     {
@@ -132,7 +132,7 @@
 
   if (!m_pitTimeoutCheckTimerActive) {
     m_pitTimeoutCheckTimerActive = true;
-    m_pitTimeoutCheckTimer->expires_from_now(boost::posix_time::milliseconds(100));
+    m_pitTimeoutCheckTimer->expires_from_now(time::milliseconds(100));
     m_pitTimeoutCheckTimer->async_wait(bind(&Face::checkPitExpire, this));
   }
 }
@@ -218,20 +218,21 @@
 }
 
 void
-Face::processEvents(Milliseconds timeout/* = 0 */, bool keepThread/* = false*/)
+Face::processEvents(const time::milliseconds& timeout/* = time::milliseconds::zero()*/,
+                    bool keepThread/* = false*/)
 {
   try
     {
-      if (timeout < 0)
+      if (timeout < time::milliseconds::zero())
         {
           // do not block if timeout is negative, but process pending events
           m_ioService->poll();
           return;
         }
 
-      if (timeout > 0)
+      if (timeout > time::milliseconds::zero())
         {
-          m_processEventsTimeoutTimer->expires_from_now(boost::posix_time::milliseconds(timeout));
+          m_processEventsTimeoutTimer->expires_from_now(time::milliseconds(timeout));
           m_processEventsTimeoutTimer->async_wait(&fireProcessEventsTimeout);
         }
 
@@ -279,13 +280,13 @@
 void
 Face::checkPitExpire()
 {
-  // Check for PIT entry timeouts.  Go backwards through the list so we can erase entries.
-  MillisecondsSince1970 nowMilliseconds = getNowMilliseconds();
+  // Check for PIT entry timeouts.
+  time::steady_clock::TimePoint now = time::steady_clock::now();
 
   PendingInterestTable::iterator i = m_pendingInterestTable.begin();
   while (i != m_pendingInterestTable.end())
     {
-      if ((*i)->isTimedOut(nowMilliseconds))
+      if ((*i)->isTimedOut(now))
         {
           // Save the PendingInterest and remove it from the PIT.  Then call the callback.
           shared_ptr<PendingInterest> pendingInterest = *i;
@@ -301,7 +302,7 @@
   if (!m_pendingInterestTable.empty()) {
     m_pitTimeoutCheckTimerActive = true;
 
-    m_pitTimeoutCheckTimer->expires_from_now(boost::posix_time::milliseconds(100));
+    m_pitTimeoutCheckTimer->expires_from_now(time::milliseconds(100));
     m_pitTimeoutCheckTimer->async_wait(bind(&Face::checkPitExpire, this));
   }
   else {
diff --git a/src/face.hpp b/src/face.hpp
index fcd9bd0..4cb4c67 100644
--- a/src/face.hpp
+++ b/src/face.hpp
@@ -17,6 +17,7 @@
 
 #include "management/controller.hpp"
 
+#include "util/scheduler.hpp"
 #include "detail/registered-prefix.hpp"
 #include "detail/pending-interest.hpp"
 
@@ -192,7 +193,8 @@
    * call this from an main event loop, you may want to catch and log/disregard all exceptions.
    */
   void 
-  processEvents(Milliseconds timeout = 0, bool keepThread = false);
+  processEvents(const time::milliseconds& timeout = time::milliseconds::zero(),
+                bool keepThread = false);
 
   void 
   shutdown();
@@ -241,9 +243,9 @@
 private:
   shared_ptr<boost::asio::io_service> m_ioService;
   shared_ptr<boost::asio::io_service::work> m_ioServiceWork; // needed if thread needs to be preserved
-  shared_ptr<boost::asio::deadline_timer> m_pitTimeoutCheckTimer;
+  shared_ptr<monotonic_deadline_timer> m_pitTimeoutCheckTimer;
   bool m_pitTimeoutCheckTimerActive;
-  shared_ptr<boost::asio::deadline_timer> m_processEventsTimeoutTimer;
+  shared_ptr<monotonic_deadline_timer> m_processEventsTimeoutTimer;
   
   shared_ptr<Transport> m_transport;
 
diff --git a/src/interest.cpp b/src/interest.cpp
index 942a5f7..229e0fb 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -29,7 +29,7 @@
 {
   if (!m_name.isPrefixOf(name))
     return false;
-  
+
   if (getMinSuffixComponents() >= 0 &&
     // Add 1 for the implicit digest.
       !(name.size() + 1 - m_name.size() >= getMinSuffixComponents()))
@@ -74,7 +74,8 @@
     os << delim << "ndn.Scope=" << interest.getScope();
     delim = '&';
   }
-  if (interest.getInterestLifetime() >= 0 && interest.getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) {
+  if (interest.getInterestLifetime() >= time::milliseconds::zero()
+      && interest.getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) {
     os << delim << "ndn.InterestLifetime=" << interest.getInterestLifetime();
     delim = '&';
   }
diff --git a/src/interest.hpp b/src/interest.hpp
index a22578f..2783aa9 100644
--- a/src/interest.hpp
+++ b/src/interest.hpp
@@ -14,55 +14,55 @@
 
 namespace ndn {
 
-const Milliseconds DEFAULT_INTEREST_LIFETIME = 4000;
+const time::seconds DEFAULT_INTEREST_LIFETIME = time::seconds(4);
 
 /**
  * An Interest holds a Name and other fields for an interest.
  */
 class Interest : public enable_shared_from_this<Interest>
 {
-public:    
+public:
   /**
    * @brief Create a new Interest with an empty name and "none" for all values.
    */
   Interest()
     : m_nonce(0)
     , m_scope(-1)
-    , m_interestLifetime(-1.0)
+    , m_interestLifetime(time::milliseconds::min())
   {
   }
 
   /**
    * @brief Create a new Interest with the given name and "none" for other values.
-   * 
+   *
    * @param name The name for the interest.
    */
-  Interest(const Name& name) 
+  Interest(const Name& name)
     : m_name(name)
     , m_nonce(0)
     , m_scope(-1)
-    , m_interestLifetime(-1.0)
+    , m_interestLifetime(time::milliseconds::min())
   {
   }
 
   /**
    * Create a new Interest with the given name and interest lifetime and "none" for other values.
    * @param name The name for the interest.
-   * @param interestLifetimeMilliseconds The interest lifetime in milliseconds, or -1 for none.
+   * @param interestLifetimeMilliseconds The interest lifetime in time::milliseconds, or -1 for none.
    */
-  Interest(const Name& name, Milliseconds interestLifetime) 
+  Interest(const Name& name, const time::milliseconds& interestLifetime)
     : m_name(name)
     , m_nonce(0)
     , m_scope(-1)
     , m_interestLifetime(interestLifetime)
   {
   }
-  
+
   Interest(const Name& name,
-           const Selectors& selectors, 
+           const Selectors& selectors,
            int scope,
-           Milliseconds interestLifetime,
-           uint32_t nonce = 0) 
+           const time::milliseconds& interestLifetime,
+           uint32_t nonce = 0)
     : m_name(name)
     , m_selectors(selectors)
     , m_nonce(nonce)
@@ -70,7 +70,7 @@
     , m_interestLifetime(interestLifetime)
   {
   }
-  
+
   /**
    * Create a new Interest for the given name and values.
    * @param name
@@ -84,13 +84,13 @@
    * @param nonce
    */
   Interest(const Name& name,
-           int minSuffixComponents, int maxSuffixComponents, 
+           int minSuffixComponents, int maxSuffixComponents,
            const Exclude& exclude,
            int childSelector,
-           bool mustBeFresh, 
+           bool mustBeFresh,
            int scope,
-           Milliseconds interestLifetime,
-           uint32_t nonce = 0) 
+           const time::milliseconds& interestLifetime,
+           uint32_t nonce = 0)
     : m_name(name)
     , m_selectors(minSuffixComponents, maxSuffixComponents, exclude, childSelector, mustBeFresh)
     , m_nonce(nonce)
@@ -121,7 +121,7 @@
   /**
    * @brief Decode from the wire format
    */
-  inline void 
+  inline void
   wireDecode(const Block &wire);
 
   /**
@@ -129,7 +129,7 @@
    */
   inline bool
   hasWire() const;
-  
+
   /**
    * Encode the name according to the "NDN URI Scheme".  If there are interest selectors, append "?" and
    * added the selectors as a query string.  For example "/test/name?ndn.ChildSelector=1".
@@ -145,7 +145,7 @@
   hasGuiders() const;
 
   /**
-   * @brief Check if Interest name matches the given name (using ndn_Name_match) and the given name also conforms to the 
+   * @brief Check if Interest name matches the given name (using ndn_Name_match) and the given name also conforms to the
    * interest selectors.
    * @param self A pointer to the ndn_Interest struct.
    * @param name A pointer to the name to check.
@@ -158,8 +158,8 @@
   ///////////////////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////////////////
   // Getters/setters
-  
-  const Name& 
+
+  const Name&
   getName() const
   {
     return m_name;
@@ -172,7 +172,7 @@
     m_wire.reset();
     return *this;
   }
-  
+
   //
 
   const Selectors&
@@ -191,7 +191,7 @@
 
   //
 
-  int 
+  int
   getScope() const
   {
     return m_scope;
@@ -206,15 +206,15 @@
   }
 
   //
-  
-  Milliseconds 
+
+  const time::milliseconds&
   getInterestLifetime() const
   {
     return m_interestLifetime;
   }
 
   Interest&
-  setInterestLifetime(Milliseconds interestLifetime)
+  setInterestLifetime(const time::milliseconds& interestLifetime)
   {
     m_interestLifetime = interestLifetime;
     m_wire.reset();
@@ -222,7 +222,7 @@
   }
 
   //
-  
+
   /**
    * @brief Get Interest's nonce
    *
@@ -256,7 +256,7 @@
   }
 
   // helper methods for LocalControlHeader
-  
+
   uint64_t
   getIncomingFaceId() const
   {
@@ -274,7 +274,7 @@
   //
 
   // NextHopFaceId helpers make sense only for Interests
-  
+
   uint64_t
   getNextHopFaceId() const
   {
@@ -290,19 +290,19 @@
   }
 
   //
-  
+
   ///////////////////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////////////////
   // Wrappers for Selectors
   //
-  
+
   int
   getMinSuffixComponents() const
   {
     return m_selectors.getMinSuffixComponents();
   }
-  
+
   Interest&
   setMinSuffixComponents(int minSuffixComponents)
   {
@@ -312,7 +312,7 @@
   }
 
   //
-  
+
   int
   getMaxSuffixComponents() const
   {
@@ -326,7 +326,7 @@
     m_wire.reset();
     return *this;
   }
-  
+
   //
 
   const Exclude&
@@ -344,8 +344,8 @@
   }
 
   //
-  
-  int 
+
+  int
   getChildSelector() const
   {
     return m_selectors.getChildSelector();
@@ -361,7 +361,7 @@
 
   //
 
-  int 
+  int
   getMustBeFresh() const
   {
     return m_selectors.getMustBeFresh();
@@ -380,7 +380,7 @@
   Selectors m_selectors;
   mutable uint32_t m_nonce;
   int m_scope;
-  Milliseconds m_interestLifetime;
+  time::milliseconds m_interestLifetime;
 
   mutable Block m_wire;
 
@@ -409,7 +409,7 @@
 Interest::hasGuiders() const
 {
   return m_scope >= 0 ||
-    m_interestLifetime >= 0 ||
+    m_interestLifetime >= time::milliseconds::zero() ||
     m_nonce > 0;
 }
 
@@ -424,14 +424,15 @@
   //                Selectors?
   //                Nonce
   //                Scope?
-  //                InterestLifetime?  
+  //                InterestLifetime?
 
   // (reverse encoding)
 
   // InterestLifetime
-  if (getInterestLifetime() >= 0 && getInterestLifetime() != DEFAULT_INTEREST_LIFETIME)
+  if (getInterestLifetime() >= time::milliseconds::zero()
+      && getInterestLifetime() != DEFAULT_INTEREST_LIFETIME)
     {
-      total_len += prependNonNegativeIntegerBlock(block, Tlv::InterestLifetime, getInterestLifetime());
+      total_len += prependNonNegativeIntegerBlock(block, Tlv::InterestLifetime, getInterestLifetime().count());
     }
 
   // Scope
@@ -451,7 +452,7 @@
 
   // Name
   total_len += getName().wireEncode(block);
-  
+
   total_len += block.prependVarNumber (total_len);
   total_len += block.prependVarNumber (Tlv::Interest);
   return total_len;
@@ -465,7 +466,7 @@
 
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
-  
+
   EncodingBuffer buffer(estimatedSize, 0);
   wireEncode(buffer);
 
@@ -474,7 +475,7 @@
 }
 
 inline void
-Interest::wireDecode(const Block &wire) 
+Interest::wireDecode(const Block &wire)
 {
   m_wire = wire;
   m_wire.parse();
@@ -484,11 +485,11 @@
   //                Selectors?
   //                Nonce
   //                Scope?
-  //                InterestLifetime?  
+  //                InterestLifetime?
 
   if (m_wire.type() != Tlv::Interest)
     throw Tlv::Error("Unexpected TLV number when decoding Interest");
-  
+
   // Name
   m_name.wireDecode(m_wire.get(Tlv::Name));
 
@@ -518,12 +519,12 @@
     }
   else
     m_scope = -1;
-  
+
   // InterestLifetime
   val = m_wire.find(Tlv::InterestLifetime);
   if (val != m_wire.elements_end())
     {
-      m_interestLifetime = readNonNegativeInteger(*val);
+      m_interestLifetime = time::milliseconds(readNonNegativeInteger(*val));
     }
   else
     {
diff --git a/src/management/ndnd-controller.cpp b/src/management/ndnd-controller.cpp
index b3b7821..1d3fb60 100644
--- a/src/management/ndnd-controller.cpp
+++ b/src/management/ndnd-controller.cpp
@@ -139,7 +139,7 @@
 
   Interest interest(interestName);
   interest.setScope(1);
-  interest.setInterestLifetime(1000);
+  interest.setInterestLifetime(time::seconds(1));
   interest.setMustBeFresh(true);
 
   m_face.expressInterest(interest,
@@ -172,7 +172,7 @@
 
   Interest interest(interestName);
   interest.setScope(1);
-  interest.setInterestLifetime(1000);
+  interest.setInterestLifetime(time::seconds(1));
   interest.setMustBeFresh(true);
 
   m_face.expressInterest(interest,
diff --git a/src/management/ndnd-face-instance.hpp b/src/management/ndnd-face-instance.hpp
index 1da6b94..60c07dc 100644
--- a/src/management/ndnd-face-instance.hpp
+++ b/src/management/ndnd-face-instance.hpp
@@ -18,7 +18,7 @@
  * An FaceInstance holds an action and  Name prefix and other fields for an forwarding entry.
  */
 class FaceInstance {
-public:    
+public:
   FaceInstance(const std::string &action,
                int64_t     faceId,
                uint32_t    ipProto,
@@ -26,7 +26,7 @@
                const std::string &port,
                const std::string &multicastInterface,
                uint32_t    multicastTtl,
-               Milliseconds freshnessPeriod) 
+               const time::milliseconds& freshnessPeriod)
     : action_(action)
     , faceId_(faceId)
     , ipProto_(ipProto)
@@ -42,73 +42,79 @@
     : faceId_(-1)
     , ipProto_(-1)
     , multicastTtl_(-1)
-    , freshnessPeriod_(-1)
+    , freshnessPeriod_(time::milliseconds::min())
   {
   }
 
   // Action
-  const std::string& 
+  const std::string&
   getAction() const { return action_; }
 
-  void 
+  void
   setAction(const std::string& action) { action_ = action; wire_.reset(); }
 
   // FaceID
   int64_t
   getFaceId() const { return faceId_; }
 
-  void 
+  void
   setFaceId(int64_t faceId) { faceId_ = faceId; wire_.reset(); }
 
   // IPProto
-  int32_t 
+  int32_t
   getIpProto() const { return ipProto_; }
 
-  void 
+  void
   setIpProto(int32_t ipProto) { ipProto_ = ipProto; wire_.reset(); }
 
   // Host
-  const std::string& 
+  const std::string&
   getHost() const { return host_; }
 
-  void 
+  void
   setHost(const std::string& host) { host_ = host; wire_.reset(); }
 
   // Port
   const std::string&
   getPort() const { return port_; }
 
-  void 
+  void
   setPort(const std::string &port) { port_ = port; wire_.reset(); }
 
   // MulticastInterface
-  const std::string& 
+  const std::string&
   getMulticastInterface() const { return multicastInterface_; }
 
-  void 
-  setMulticastInterface(const std::string& multicastInterface) { multicastInterface_ = multicastInterface; wire_.reset(); }
+  void
+  setMulticastInterface(const std::string& multicastInterface)
+  {
+    multicastInterface_ = multicastInterface; wire_.reset();
+  }
 
   // MulticastTTL
   int32_t
   getMulticastTtl() const { return multicastTtl_; }
 
-  void 
+  void
   setMulticastTtl(int32_t multicastTtl) { multicastTtl_ = multicastTtl; wire_.reset(); }
 
   // Freshness
-  int 
+  const time::milliseconds&
   getFreshnessPeriod() const { return freshnessPeriod_; }
 
-  void 
-  setFreshnessPeriod(int freshnessPeriod) { freshnessPeriod_ = freshnessPeriod; wire_.reset(); }
+  void
+  setFreshnessPeriod(const time::milliseconds& freshnessPeriod)
+  {
+    freshnessPeriod_ = freshnessPeriod; wire_.reset();
+  }
 
   // Wire
   inline const Block&
   wireEncode() const;
-  
-  inline void 
+
+  inline void
   wireDecode(const Block &wire);
-  
+
 private:
   std::string action_;
   int64_t     faceId_;
@@ -117,8 +123,8 @@
   std::string port_;
   std::string multicastInterface_;
   int32_t     multicastTtl_;
-  Milliseconds freshnessPeriod_;
-  
+  time::milliseconds freshnessPeriod_;
+
   mutable Block wire_;
 };
 
@@ -137,7 +143,7 @@
   //                  MulticastInterface?
   //                  MulticastTTL?
   //                  FreshnessPeriod?
-  
+
   wire_ = Block(tlv::ndnd::FaceInstance);
 
   // Action
@@ -160,7 +166,7 @@
       wire_.push_back
         (nonNegativeIntegerBlock(tlv::ndnd::IPProto, ipProto_));
     }
-  
+
   // Host
   if (!host_.empty())
     {
@@ -190,17 +196,17 @@
     }
 
   // FreshnessPeriod
-  if (freshnessPeriod_ >= 0)
+  if (freshnessPeriod_ >= time::milliseconds::zero())
     {
       wire_.push_back
-        (nonNegativeIntegerBlock(Tlv::FreshnessPeriod, freshnessPeriod_));
+        (nonNegativeIntegerBlock(Tlv::FreshnessPeriod, freshnessPeriod_.count()));
     }
-  
+
   wire_.encode();
-  return wire_;    
+  return wire_;
 }
-  
-inline void 
+
+inline void
 FaceInstance::wireDecode(const Block &wire)
 {
   action_.clear();
@@ -210,7 +216,7 @@
   port_.clear();
   multicastInterface_.clear();
   multicastTtl_ = -1;
-  freshnessPeriod_ = -1;
+  freshnessPeriod_ = time::milliseconds::min();
 
   wire_ = wire;
   wire_.parse();
@@ -278,7 +284,7 @@
   val = wire_.find(Tlv::FreshnessPeriod);
   if (val != wire_.elements_end())
     {
-      freshnessPeriod_ = readNonNegativeInteger(*val);
+      freshnessPeriod_ = time::milliseconds(readNonNegativeInteger(*val));
     }
 }
 
@@ -286,7 +292,7 @@
 operator << (std::ostream &os, const FaceInstance &entry)
 {
   os << "FaceInstance(";
-  
+
   // Action
   if (!entry.getAction().empty())
     {
@@ -330,7 +336,7 @@
     }
 
   // FreshnessPeriod
-  if (entry.getFreshnessPeriod() >= 0)
+  if (entry.getFreshnessPeriod() >= time::milliseconds::zero())
     {
       os << "FreshnessPeriod:" << entry.getFreshnessPeriod() << ", ";
     }
@@ -343,4 +349,3 @@
 } // namespace ndn
 
 #endif // NDN_MANAGEMENT_NDND_FACE_INSTANCE_HPP
-
diff --git a/src/management/ndnd-forwarding-entry.hpp b/src/management/ndnd-forwarding-entry.hpp
index 3d262f1..03272b1 100644
--- a/src/management/ndnd-forwarding-entry.hpp
+++ b/src/management/ndnd-forwarding-entry.hpp
@@ -20,12 +20,12 @@
  * An ForwardingEntry holds an action and  Name prefix and other fields for an forwarding entry.
  */
 class ForwardingEntry {
-public:    
+public:
   ForwardingEntry(const std::string& action,
                   const Name& prefix,
                   int faceId = -1,
                   const ForwardingFlags& forwardingFlags = ForwardingFlags(),
-                  int freshnessPeriod = -1) 
+                  time::milliseconds freshnessPeriod = time::milliseconds::min())
     : action_(action)
     , prefix_(prefix)
     , faceId_(faceId)
@@ -36,52 +36,52 @@
 
   ForwardingEntry()
   : faceId_(-1)
-  , freshnessPeriod_(-1)
+  , freshnessPeriod_(time::milliseconds::min())
   {
   }
-  
-  const std::string& 
+
+  const std::string&
   getAction() const { return action_; }
 
-  void 
+  void
   setAction(const std::string& action) { action_ = action; wire_.reset(); }
-    
-  const Name& 
+
+  const Name&
   getPrefix() const { return prefix_; }
-  
+
   void
   setPrefix(const Name &prefix) { prefix_ = prefix; wire_.reset(); }
-  
-  int 
+
+  int
   getFaceId() const { return faceId_; }
 
-  void 
+  void
   setFaceId(int faceId) { faceId_ = faceId; wire_.reset(); }
-      
-  const ForwardingFlags& 
+
+  const ForwardingFlags&
   getForwardingFlags() const { return forwardingFlags_; }
 
-  void 
+  void
   setForwardingFlags(const ForwardingFlags& forwardingFlags) { forwardingFlags_ = forwardingFlags; wire_.reset(); }
-      
-  int 
+
+  const time::milliseconds&
   getFreshnessPeriod() const { return freshnessPeriod_; }
 
-  void 
-  setFreshnessPeriod(int freshnessPeriod) { freshnessPeriod_ = freshnessPeriod; wire_.reset(); }
+  void
+  setFreshnessPeriod(const time::milliseconds& freshnessPeriod) { freshnessPeriod_ = freshnessPeriod; wire_.reset(); }
 
   inline const Block&
   wireEncode() const;
-  
-  inline void 
+
+  inline void
   wireDecode(const Block &wire);
-  
+
 private:
   std::string action_;   /**< empty for none. */
   Name prefix_;
   int faceId_;           /**< -1 for none. */
   ForwardingFlags forwardingFlags_;
-  int freshnessPeriod_; /**< -1 for none. */
+  time::milliseconds freshnessPeriod_; /**< time::milliseconds::min() for none. */
 
   mutable Block wire_;
 };
@@ -98,7 +98,7 @@
   //                       FaceID?
   //                       ForwardingFlags?
   //                       FreshnessPeriod?
-  
+
   wire_ = Block(tlv::ndnd::ForwardingEntry);
 
   // Action
@@ -124,24 +124,24 @@
     (forwardingFlags_.wireEncode());
 
   // FreshnessPeriod
-  if (freshnessPeriod_ >= 0)
+  if (freshnessPeriod_ >= time::milliseconds::zero())
     {
       wire_.push_back
-        (nonNegativeIntegerBlock(Tlv::FreshnessPeriod, freshnessPeriod_));
+        (nonNegativeIntegerBlock(Tlv::FreshnessPeriod, freshnessPeriod_.count()));
     }
-  
+
   wire_.encode();
-  return wire_;    
+  return wire_;
 }
-  
-inline void 
+
+inline void
 ForwardingEntry::wireDecode(const Block &wire)
 {
   action_.clear();
   prefix_.clear();
   faceId_ = -1;
   forwardingFlags_ = ForwardingFlags();
-  freshnessPeriod_ = -1;
+  freshnessPeriod_ = time::milliseconds::min();
 
   wire_ = wire;
   wire_.parse();
@@ -185,7 +185,7 @@
   val = wire_.find(Tlv::FreshnessPeriod);
   if (val != wire_.elements_end())
     {
-      freshnessPeriod_ = readNonNegativeInteger(*val);
+      freshnessPeriod_ = time::milliseconds(readNonNegativeInteger(*val));
     }
 }
 
@@ -193,7 +193,7 @@
 operator << (std::ostream &os, const ForwardingEntry &entry)
 {
   os << "ForwardingEntry(";
-  
+
   // Action
   if (!entry.getAction().empty())
     {
@@ -213,7 +213,7 @@
   os << "ForwardingFlags:" << entry.getForwardingFlags() << ", ";
 
   // FreshnessPeriod
-  if (entry.getFreshnessPeriod() >= 0)
+  if (entry.getFreshnessPeriod() >= time::milliseconds::zero())
     {
       os << "FreshnessPeriod:" << entry.getFreshnessPeriod() << ", ";
     }
diff --git a/src/management/nfd-status.hpp b/src/management/nfd-status.hpp
index fa7f884..e00c705 100644
--- a/src/management/nfd-status.hpp
+++ b/src/management/nfd-status.hpp
@@ -44,8 +44,6 @@
   wireDecode(const Block& payload);
 
 public:
-  typedef boost::chrono::time_point<boost::chrono::system_clock, boost::chrono::seconds> Timestamp;
-
   int
   getNfdVersion() const
   {
@@ -58,26 +56,26 @@
     m_nfdVersion = nfdVersion;
   }
 
-  Timestamp
+  const time::system_clock::TimePoint&
   getStartTimestamp() const
   {
     return m_startTimestamp;
   }
 
   void
-  setStartTimestamp(Timestamp startTimestamp)
+  setStartTimestamp(const time::system_clock::TimePoint& startTimestamp)
   {
     m_startTimestamp = startTimestamp;
   }
 
-  Timestamp
+  const time::system_clock::TimePoint&
   getCurrentTimestamp() const
   {
     return m_currentTimestamp;
   }
 
   void
-  setCurrentTimestamp(Timestamp currentTimestamp)
+  setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp)
   {
     m_currentTimestamp = currentTimestamp;
   }
@@ -192,8 +190,8 @@
 
 private:
   int       m_nfdVersion;
-  Timestamp m_startTimestamp;
-  Timestamp m_currentTimestamp;
+  time::system_clock::TimePoint m_startTimestamp;
+  time::system_clock::TimePoint m_currentTimestamp;
   size_t    m_nNameTreeEntries;
   size_t    m_nFibEntries;
   size_t    m_nPitEntries;
@@ -205,24 +203,22 @@
   int       m_nOutDatas;
 };
 
-BOOST_STATIC_ASSERT((boost::is_same<Status::Timestamp::period, boost::ratio<1> >::value));
-
 inline
 Status::Status()
-{
-  m_nfdVersion = 0;
-  m_startTimestamp = Timestamp::min();
-  m_currentTimestamp = Timestamp::min();
-  m_nNameTreeEntries = 0;
-  m_nFibEntries = 0;
-  m_nPitEntries = 0;
-  m_nMeasurementsEntries = 0;
-  m_nCsEntries = 0;
-  m_nInInterests = 0;
-  m_nOutInterests = 0;
-  m_nInDatas = 0;
-  m_nOutDatas = 0;
-}
+  : m_nfdVersion(0)
+  , m_startTimestamp(time::system_clock::TimePoint::min())
+  , m_currentTimestamp(time::system_clock::TimePoint::min())
+  , m_nNameTreeEntries(0)
+  , m_nFibEntries(0)
+  , m_nPitEntries(0)
+  , m_nMeasurementsEntries(0)
+  , m_nCsEntries(0)
+  , m_nInInterests(0)
+  , m_nOutInterests(0)
+  , m_nInDatas(0)
+  , m_nOutDatas(0)
+  {
+  }
 
 template<bool T>
 inline size_t
@@ -249,9 +245,9 @@
   total_len += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NNameTreeEntries,
                                               m_nNameTreeEntries);
   total_len += prependNonNegativeIntegerBlock(encoder, tlv::nfd::CurrentTimestamp,
-               m_currentTimestamp.time_since_epoch().count());
+                                              time::toUnixTimestamp(m_currentTimestamp).count());
   total_len += prependNonNegativeIntegerBlock(encoder, tlv::nfd::StartTimestamp,
-               m_startTimestamp.time_since_epoch().count());
+                                              time::toUnixTimestamp(m_startTimestamp).count());
   total_len += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NfdVersion,
                                               m_nfdVersion);
 
@@ -262,8 +258,8 @@
 Status::wireDecode(const Block& payload)
 {
   m_nfdVersion = 0;
-  m_startTimestamp = Timestamp::min();
-  m_currentTimestamp = Timestamp::min();
+  m_startTimestamp = time::system_clock::TimePoint::min();
+  m_currentTimestamp = time::system_clock::TimePoint::min();
   m_nNameTreeEntries = 0;
   m_nFibEntries = 0;
   m_nPitEntries = 0;
@@ -288,12 +284,12 @@
 
   val = payload.find(tlv::nfd::StartTimestamp);
   if (val != payload.elements_end()) {
-    m_startTimestamp = Timestamp(boost::chrono::seconds(readNonNegativeInteger(*val)));
+    m_startTimestamp = time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*val)));
   }
 
   val = payload.find(tlv::nfd::CurrentTimestamp);
   if (val != payload.elements_end()) {
-    m_currentTimestamp = Timestamp(boost::chrono::seconds(readNonNegativeInteger(*val)));
+    m_currentTimestamp = time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*val)));
   }
 
   val = payload.find(tlv::nfd::NNameTreeEntries);
diff --git a/src/management/nrd-prefix-reg-options.hpp b/src/management/nrd-prefix-reg-options.hpp
index 412194b..c80d04b 100644
--- a/src/management/nrd-prefix-reg-options.hpp
+++ b/src/management/nrd-prefix-reg-options.hpp
@@ -26,13 +26,13 @@
  */
 class PrefixRegOptions {
 public:
-  struct Error : public Tlv::Error { Error(const std::string &what) : Tlv::Error(what) {} };
+  struct Error : public Tlv::Error { Error(const std::string& what) : Tlv::Error(what) {} };
 
   PrefixRegOptions()
-    : m_faceId (INVALID_FACE_ID)
-    , m_flags (DEFAULT_FLAGS)
-    , m_cost (DEFAULT_COST)
-    , m_expirationPeriod (-1)
+    : m_faceId(INVALID_FACE_ID)
+    , m_flags(DEFAULT_FLAGS)
+    , m_cost(DEFAULT_COST)
+    , m_expirationPeriod(time::milliseconds::min())
   {
   }
 
@@ -117,14 +117,14 @@
 
   //
 
-  Milliseconds
+  const time::milliseconds&
   getExpirationPeriod() const
   {
     return m_expirationPeriod;
   }
 
   PrefixRegOptions&
-  setExpirationPeriod(Milliseconds expirationPeriod)
+  setExpirationPeriod(const time::milliseconds& expirationPeriod)
   {
     m_expirationPeriod = expirationPeriod;
     m_wire.reset();
@@ -152,7 +152,7 @@
   uint64_t m_faceId;
   uint64_t m_flags;
   uint64_t m_cost;
-  Milliseconds m_expirationPeriod;
+  time::milliseconds m_expirationPeriod;
   std::string m_protocol;
 
   mutable Block m_wire;
@@ -184,10 +184,11 @@
     }
 
   // ExpirationPeriod
-  if (m_expirationPeriod > 0)
+  if (m_expirationPeriod > time::milliseconds::zero())
     {
       total_len += prependNonNegativeIntegerBlock(block,
-                                                  tlv::nrd::ExpirationPeriod, m_expirationPeriod);
+                                                  tlv::nrd::ExpirationPeriod,
+                                                  m_expirationPeriod.count());
     }
 
   // Cost
@@ -247,7 +248,7 @@
   m_faceId = INVALID_FACE_ID;
   m_flags = DEFAULT_FLAGS;
   m_cost = DEFAULT_COST;
-  m_expirationPeriod = -1;
+  m_expirationPeriod = time::milliseconds::min();
   m_protocol.clear();
 
   m_wire = wire;
@@ -289,7 +290,7 @@
   val = m_wire.find(tlv::nrd::ExpirationPeriod);
   if (val != m_wire.elements_end())
     {
-      m_expirationPeriod = readNonNegativeInteger(*val);
+      m_expirationPeriod = time::milliseconds(readNonNegativeInteger(*val));
     }
 
   // Protocol
diff --git a/src/meta-info.hpp b/src/meta-info.hpp
index 2bccd37..42875d8 100644
--- a/src/meta-info.hpp
+++ b/src/meta-info.hpp
@@ -22,11 +22,11 @@
     TYPE_LINK = 1,
     TYPE_KEY = 2
   };
-  
+
   MetaInfo()
     : m_type(TYPE_DEFAULT)
     , m_freshnessPeriod(-1)
-  {   
+  {
   }
 
   MetaInfo(const Block& block)
@@ -38,21 +38,21 @@
   size_t
   wireEncode(EncodingImpl<T> &block) const;
 
-  const Block& 
+  const Block&
   wireEncode() const;
-  
+
   void
-  wireDecode(const Block &wire);  
-  
+  wireDecode(const Block &wire);
+
   ///////////////////////////////////////////////////////////////////////////////
   // Getters/setters
-  
-  uint32_t 
+
+  uint32_t
   getType() const
   {
     return m_type;
   }
-  
+
   MetaInfo&
   setType(uint32_t type)
   {
@@ -60,15 +60,15 @@
     m_type = type;
     return *this;
   }
-  
-  Milliseconds 
+
+  const time::milliseconds&
   getFreshnessPeriod() const
   {
     return m_freshnessPeriod;
   }
-  
+
   MetaInfo&
-  setFreshnessPeriod(Milliseconds freshnessPeriod)
+  setFreshnessPeriod(const time::milliseconds& freshnessPeriod)
   {
     m_wire.reset();
     m_freshnessPeriod = freshnessPeriod;
@@ -88,10 +88,10 @@
     m_finalBlockId = finalBlockId;
     return *this;
   }
-  
+
 private:
   uint32_t m_type;
-  Milliseconds m_freshnessPeriod;
+  time::milliseconds m_freshnessPeriod;
   name::Component m_finalBlockId;
 
   mutable Block m_wire;
@@ -105,7 +105,7 @@
   //                ContentType?
   //                FreshnessPeriod?
   //                FinalBlockId?
-  
+
   size_t total_len = 0;
 
   // FinalBlockId
@@ -113,11 +113,12 @@
     {
       total_len += prependNestedBlock(blk, Tlv::FinalBlockId, m_finalBlockId);
     }
-  
+
   // FreshnessPeriod
-  if (m_freshnessPeriod >= 0)
+  if (m_freshnessPeriod >= time::milliseconds::zero())
     {
-      total_len += prependNonNegativeIntegerBlock(blk, Tlv::FreshnessPeriod, m_freshnessPeriod);
+      total_len += prependNonNegativeIntegerBlock(blk, Tlv::FreshnessPeriod,
+                                                  m_freshnessPeriod.count());
     }
 
   // ContentType
@@ -131,7 +132,7 @@
   return total_len;
 }
 
-inline const Block& 
+inline const Block&
 MetaInfo::wireEncode() const
 {
   if (m_wire.hasWire ())
@@ -139,14 +140,14 @@
 
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
-  
+
   EncodingBuffer buffer(estimatedSize, 0);
   wireEncode(buffer);
 
   m_wire = buffer.block();
   return m_wire;
 }
-  
+
 inline void
 MetaInfo::wireDecode(const Block &wire)
 {
@@ -156,7 +157,7 @@
   // MetaInfo ::= META-INFO-TYPE TLV-LENGTH
   //                ContentType?
   //                FreshnessPeriod?
-  
+
   // ContentType
   Block::element_const_iterator val = m_wire.find(Tlv::ContentType);
   if (val != m_wire.elements().end())
@@ -170,10 +171,10 @@
   val = m_wire.find(Tlv::FreshnessPeriod);
   if (val != m_wire.elements().end())
     {
-      m_freshnessPeriod = readNonNegativeInteger(*val);
+      m_freshnessPeriod = time::milliseconds(readNonNegativeInteger(*val));
     }
   else
-    m_freshnessPeriod = -1;
+    m_freshnessPeriod = time::milliseconds::min();
 
   // FinalBlockId
   val = m_wire.find(Tlv::FinalBlockId);
@@ -197,7 +198,7 @@
   os << "ContentType: " << info.getType();
 
   // FreshnessPeriod
-  if (info.getFreshnessPeriod() >= 0) {
+  if (info.getFreshnessPeriod() >= time::milliseconds::zero()) {
     os << ", FreshnessPeriod: " << info.getFreshnessPeriod();
   }
 
diff --git a/src/name.cpp b/src/name.cpp
index a355e4a..846cabb 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -91,7 +91,7 @@
 Name& 
 Name::appendVersion()
 {
-  appendVersion(ndn_getNowMilliseconds());
+  appendVersion(time::toUnixTimestamp(time::system_clock::now()).count());
   return *this;
 }
 
diff --git a/src/security/certificate-cache-ttl.cpp b/src/security/certificate-cache-ttl.cpp
index 6f831d0..0997182 100644
--- a/src/security/certificate-cache-ttl.cpp
+++ b/src/security/certificate-cache-ttl.cpp
@@ -17,32 +17,34 @@
 
 namespace ndn {
 
-CertificateCacheTtl::CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, int defaultTtl)
+CertificateCacheTtl::CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, const time::seconds& defaultTtl)
   : m_defaultTtl(defaultTtl)
   , m_scheduler(*io)
 {}
 
 CertificateCacheTtl::~CertificateCacheTtl()
 {}
-  
+
 void
 CertificateCacheTtl::insertCertificate(ptr_lib::shared_ptr<const IdentityCertificate> certificate)
 {
-  time::Duration expire = (certificate->getFreshnessPeriod() >= 0 ? time::milliseconds(certificate->getFreshnessPeriod()) : time::seconds(m_defaultTtl));
+  time::milliseconds expire = (certificate->getFreshnessPeriod() >= time::seconds::zero() ?
+                         certificate->getFreshnessPeriod() : m_defaultTtl);
 
   Name trackerIndex = certificate->getName().getPrefix(-1);
   EventTracker::iterator it = m_tracker.find(trackerIndex);
   if(it != m_tracker.end())
       m_scheduler.cancelEvent(m_tracker[trackerIndex]);
 
-  m_scheduler.scheduleEvent(time::seconds(0), bind(&CertificateCacheTtl::insert, this, certificate));  
-  m_tracker[trackerIndex] = m_scheduler.scheduleEvent(expire, bind(&CertificateCacheTtl::remove, this, certificate->getName()));
+  m_scheduler.scheduleEvent(time::seconds(0), bind(&CertificateCacheTtl::insert, this, certificate));
+  m_tracker[trackerIndex] = m_scheduler.scheduleEvent(expire, bind(&CertificateCacheTtl::remove,
+                                                                   this, certificate->getName()));
 
 }
 
 void
 CertificateCacheTtl::insert(ptr_lib::shared_ptr<const IdentityCertificate> certificate)
-{ 
+{
   Name name = certificate->getName().getPrefix(-1);
   m_cache[name] = certificate;
 }
@@ -56,7 +58,7 @@
     m_cache.erase(it);
 }
 
-ptr_lib::shared_ptr<const IdentityCertificate> 
+ptr_lib::shared_ptr<const IdentityCertificate>
 CertificateCacheTtl::getCertificate(const Name & certificateName)
 {
   Cache::iterator it = m_cache.find(certificateName);
@@ -67,5 +69,3 @@
 }
 
 } // namespace ndn
-
-
diff --git a/src/security/certificate-cache-ttl.hpp b/src/security/certificate-cache-ttl.hpp
index 9ac91d5..1e31e9c 100644
--- a/src/security/certificate-cache-ttl.hpp
+++ b/src/security/certificate-cache-ttl.hpp
@@ -14,25 +14,25 @@
 #include "../util/time.hpp"
 
 namespace ndn {
- 
+
 class CertificateCacheTtl : public CertificateCache
 {
 public:
-  CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, int defaultTtl = 3600);
-  
+  CertificateCacheTtl(shared_ptr<boost::asio::io_service> io, const time::seconds& defaultTtl = time::seconds(3600));
+
   virtual
   ~CertificateCacheTtl();
-    
+
   virtual void
   insertCertificate(ptr_lib::shared_ptr<const IdentityCertificate> certificate);
-  
-  virtual ptr_lib::shared_ptr<const IdentityCertificate> 
+
+  virtual ptr_lib::shared_ptr<const IdentityCertificate>
   getCertificate(const Name & certificateNameWithoutVersion);
 
-private:  
+private:
   void
   insert(ptr_lib::shared_ptr<const IdentityCertificate> certificate);
-  
+
   void
   remove(const Name &certificateName);
 
@@ -40,7 +40,7 @@
   typedef std::map<Name, ptr_lib::shared_ptr<const IdentityCertificate> > Cache;
   typedef std::map<Name, EventId> EventTracker;
 
-  int m_defaultTtl;
+  time::seconds m_defaultTtl;
   Cache m_cache;
   EventTracker m_tracker;
   Scheduler m_scheduler;
diff --git a/src/security/certificate.cpp b/src/security/certificate.cpp
index 0312fd5..931a40e 100644
--- a/src/security/certificate.cpp
+++ b/src/security/certificate.cpp
@@ -26,8 +26,8 @@
 namespace ndn {
 
 Certificate::Certificate()
-  : notBefore_(std::numeric_limits<MillisecondsSince1970>::max())
-  , notAfter_(std::numeric_limits<MillisecondsSince1970>::min())
+  : notBefore_(time::system_clock::TimePoint::max())
+  , notAfter_(time::system_clock::TimePoint::min())
 {}
 
 Certificate::Certificate(const Data& data)
@@ -47,18 +47,16 @@
 bool
 Certificate::isTooEarly()
 {
-  MillisecondsSince1970 now = ndn_getNowMilliseconds();
-  if(now < notBefore_)
+  if(time::system_clock::now() < notBefore_)
     return true;
   else
     return false;
 }
 
-bool 
+bool
 Certificate::isTooLate()
 {
-  MillisecondsSince1970 now = ndn_getNowMilliseconds();
-  if(now > notAfter_)
+  if(time::system_clock::now() > notAfter_)
     return true;
   else
     return false;
@@ -106,7 +104,7 @@
 
   OBufferStream os;
   CryptoPP::FileSink sink(os);
-  
+
   // idCert ::= SEQUENCE {
   //     validity            Validity,
   //     subject             Name,
@@ -126,7 +124,7 @@
 
     // Name ::= CHOICE {
     //     RDNSequence   }
-    // 
+    //
     // RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
     DERSequenceEncoder name(idCert);
     {
@@ -137,7 +135,7 @@
         }
     }
     name.MessageEnd();
-  
+
     // SubjectPublicKeyInfo
     key_.encode(idCert);
 
@@ -151,7 +149,7 @@
       {
         DERSequenceEncoder extensions(idCert);
         {
-          
+
           for(ExtensionList::iterator it = extensionList_.begin();
               it != extensionList_.end(); ++it)
             {
@@ -168,14 +166,14 @@
   setContentType(MetaInfo::TYPE_KEY);
 }
 
-void 
+void
 Certificate::decode()
 {
   using namespace CryptoPP;
 
   OBufferStream os;
   CryptoPP::StringSource source(getContent().value(), getContent().value_size(), true);
-  
+
   // idCert ::= SEQUENCE {
   //     validity            Validity,
   //     subject             Name,
@@ -195,7 +193,7 @@
 
     // Name ::= CHOICE {
     //     RDNSequence   }
-    // 
+    //
     // RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
     subjectDescriptionList_.clear();
     BERSequenceDecoder name(idCert);
@@ -206,7 +204,7 @@
         }
     }
     name.MessageEnd();
-  
+
     // SubjectPublicKeyInfo ::= SEQUENCE {
     //     algorithm           AlgorithmIdentifier
     //     keybits             BIT STRING   }
@@ -235,18 +233,18 @@
   idCert.MessageEnd();
 }
 
-void 
+void
 Certificate::printCertificate(std::ostream &os) const
 {
   os << "Certificate name:" << endl;
   os << "  " << getName() << endl;
   os << "Validity:" << endl;
   {
-    os << "  NotBefore: " << toIsoString(notBefore_) << endl;
-    os << "  NotAfter: "  << toIsoString(notAfter_)  << endl;
+    os << "  NotBefore: " << time::toIsoString(notBefore_) << endl;
+    os << "  NotAfter: "  << time::toIsoString(notAfter_)  << endl;
   }
 
-  os << "Subject Description:" << endl;  
+  os << "Subject Description:" << endl;
   for(SubjectDescriptionList::const_iterator it = subjectDescriptionList_.begin();
       it != subjectDescriptionList_.end(); ++it)
     {
@@ -256,7 +254,7 @@
   os << "Public key bits:" << endl;
   CryptoPP::Base64Encoder encoder(new CryptoPP::FileSink(os), true, 64);
   key_.encode(encoder);
-  
+
   // ndnboost::iostreams::stream<ndnboost::iostreams::array_source> is((const char*)key_.getKeyDer().buf(), key_.getKeyDer().size());
 
   // ptr_lib::shared_ptr<der::DerNode> keyRoot = der::DerNode::parse(reinterpret_cast<der::InputIterator&> (is));
diff --git a/src/security/certificate.hpp b/src/security/certificate.hpp
index 35934d0..d27f7a4 100644
--- a/src/security/certificate.hpp
+++ b/src/security/certificate.hpp
@@ -35,16 +35,16 @@
    * @param data The data packet with the content to decode.
    */
   Certificate(const Data& data);
- 
+
   /**
    * The virtual destructor.
    */
-  virtual 
+  virtual
   ~Certificate();
 
   inline void
   wireDecode(const Block &wire);
-  
+
   /**
    * encode certificate info into content
    */
@@ -55,63 +55,63 @@
    * Add a subject description.
    * @param description The description to be added.
    */
-  void 
+  void
   addSubjectDescription(const CertificateSubjectDescription& description) { subjectDescriptionList_.push_back(description); }
 
-  const SubjectDescriptionList& 
+  const SubjectDescriptionList&
   getSubjectDescriptionList() const { return subjectDescriptionList_; }
-  
-  SubjectDescriptionList& 
+
+  SubjectDescriptionList&
   getSubjectDescriptionList() { return subjectDescriptionList_; }
- 
+
   /**
    * Add a certificate extension.
    * @param extension the extension to be added
    */
-  void 
+  void
   addExtension(const CertificateExtension& extension) { extensionList_.push_back(extension); }
 
   const ExtensionList&
   getExtensionList() const { return extensionList_; }
-  
+
   ExtensionList&
   getExtensionList() { return extensionList_; }
 
-  void 
-  setNotBefore(const MillisecondsSince1970& notBefore) { notBefore_ = notBefore; }
+  void
+  setNotBefore(const time::system_clock::TimePoint& notBefore) { notBefore_ = notBefore; }
 
-  MillisecondsSince1970& 
+  time::system_clock::TimePoint&
   getNotBefore() { return notBefore_; }
-  
-  const MillisecondsSince1970& 
+
+  const time::system_clock::TimePoint&
   getNotBefore() const { return notBefore_; }
 
   void
-  setNotAfter(const MillisecondsSince1970& notAfter) { notAfter_ = notAfter; }
+  setNotAfter(const time::system_clock::TimePoint& notAfter) { notAfter_ = notAfter; }
 
-  MillisecondsSince1970& 
+  time::system_clock::TimePoint&
   getNotAfter() { return notAfter_; }
 
-  const MillisecondsSince1970& 
+  const time::system_clock::TimePoint&
   getNotAfter() const { return notAfter_; }
 
   void
   setPublicKeyInfo(const PublicKey& key) { key_ = key; }
-  
-  PublicKey& 
+
+  PublicKey&
   getPublicKeyInfo() { return key_; }
 
-  const PublicKey& 
+  const PublicKey&
   getPublicKeyInfo() const { return key_; }
 
-  // virtual Name 
+  // virtual Name
   // getPublicKeyName() const = 0;
-  
+
   /**
    * Check if the certificate is valid.
    * @return True if the current time is earlier than notBefore.
    */
-  bool 
+  bool
   isTooEarly();
 
   /**
@@ -121,7 +121,7 @@
   bool
   isTooLate();
 
-  void 
+  void
   printCertificate(std::ostream &os) const;
 
 protected:
@@ -130,8 +130,8 @@
 
 protected:
   SubjectDescriptionList subjectDescriptionList_;
-  MillisecondsSince1970 notBefore_;
-  MillisecondsSince1970 notAfter_;
+  time::system_clock::TimePoint notBefore_;
+  time::system_clock::TimePoint notAfter_;
   PublicKey key_;
   ExtensionList extensionList_;
 };
diff --git a/src/security/key-chain.hpp b/src/security/key-chain.hpp
index 28642ae..e58cbf9 100644
--- a/src/security/key-chain.hpp
+++ b/src/security/key-chain.hpp
@@ -124,8 +124,8 @@
   shared_ptr<IdentityCertificate>
   prepareUnsignedIdentityCertificate(const Name& keyName,
                                      const Name& signingIdentity,
-                                     const MillisecondsSince1970& notBefore,
-                                     const MillisecondsSince1970& notAfter,
+                                     const time::system_clock::TimePoint& notBefore,
+                                     const time::system_clock::TimePoint& notAfter,
                                      const std::vector<CertificateSubjectDescription>& subjectDescription)
 
   {
@@ -360,8 +360,8 @@
     certificateName.append("KEY").append(keyName.get(-1)).append("ID-CERT").appendVersion();
 
     certificate->setName(certificateName);
-    certificate->setNotBefore(getNow());
-    certificate->setNotAfter(getNow() + 630720000 /* 20 years*/);
+    certificate->setNotBefore(time::system_clock::now());
+    certificate->setNotAfter(time::system_clock::now() + time::days(7300)/* ~20 years*/);
     certificate->setPublicKeyInfo(*pubKey);
     certificate->addSubjectDescription(CertificateSubjectDescription("2.5.4.41", keyName.toUri()));
     certificate->encode();
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 16041d3..aeb34dd 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -365,9 +365,11 @@
 //   sqlite3_bind_text(statement, 3, identityName, SQLITE_STATIC);
 //   sqlite3_bind_text(statement, 4, keyId, SQLITE_STATIC);
 
-//   // Convert from milliseconds to seconds since 1/1/1970.
-//   sqlite3_bind_int64(statement, 5, static_cast<sqlite3_int64>(certificate.getNotBefore() / 1000));
-//   sqlite3_bind_int64(statement, 6, static_cast<sqlite3_int64>(certificate.getNotAfter() / 1000));
+//   // Convert from time::milliseconds to time::seconds since 1/1/1970.
+// sqlite3_bind_int64(statement, 5, static_cast<sqlite3_int64>(
+//                                    time::toUnixTimestamp(certificate.getNotBefore()).count()));
+// sqlite3_bind_int64(statement, 6, static_cast<sqlite3_int64>(
+//                                    time::toUnixTimestamp(certificate.getNotAfter()).count()));
 
 //   sqlite3_bind_blob(statement, 7, certificate.wireEncode().wire(), certificate.wireEncode().size(), SQLITE_STATIC);
 
@@ -420,9 +422,10 @@
   sqlite3_bind_text(statement, 3, identity.toUri(), SQLITE_TRANSIENT);
   sqlite3_bind_text(statement, 4, keyId, SQLITE_STATIC);
 
-  // Convert from milliseconds to seconds since 1/1/1970.
-  sqlite3_bind_int64(statement, 5, static_cast<sqlite3_int64>(certificate.getNotBefore() / 1000));
-  sqlite3_bind_int64(statement, 6, static_cast<sqlite3_int64>(certificate.getNotAfter() / 1000));
+  sqlite3_bind_int64(statement, 5, static_cast<sqlite3_int64>(
+                                     time::toUnixTimestamp(certificate.getNotBefore()).count()));
+  sqlite3_bind_int64(statement, 6, static_cast<sqlite3_int64>(
+                                     time::toUnixTimestamp(certificate.getNotAfter()).count()));
 
   sqlite3_bind_blob(statement, 7, certificate.wireEncode().wire(), certificate.wireEncode().size(), SQLITE_TRANSIENT);
 
@@ -447,7 +450,8 @@
   if (res == SQLITE_ROW)
     {
       shared_ptr<IdentityCertificate> certificate = make_shared<IdentityCertificate>();
-      certificate->wireDecode(Block((const uint8_t*)sqlite3_column_blob(statement, 0), sqlite3_column_bytes(statement, 0)));
+      certificate->wireDecode(Block((const uint8_t*)sqlite3_column_blob(statement, 0),
+                                    sqlite3_column_bytes(statement, 0)));
       sqlite3_finalize(statement);
       return certificate;
     }
diff --git a/src/security/sec-public-info.hpp b/src/security/sec-public-info.hpp
index e1e0fbe..0861b67 100644
--- a/src/security/sec-public-info.hpp
+++ b/src/security/sec-public-info.hpp
@@ -402,7 +402,7 @@
   else
     oss << "dsk-";
 
-  oss << getNow();
+  oss << time::toUnixTimestamp(time::system_clock::now()).count();
   
   Name keyName = Name(identityName).append(oss.str());
 
diff --git a/src/transport/stream-transport.hpp b/src/transport/stream-transport.hpp
index 1bde91b..8562d88 100644
--- a/src/transport/stream-transport.hpp
+++ b/src/transport/stream-transport.hpp
@@ -86,7 +86,7 @@
     if (!m_connectionInProgress) {
       m_connectionInProgress = true;
 
-      // Wait at most 4 seconds to connect
+      // Wait at most 4 time::seconds to connect
       /// @todo Decide whether this number should be configurable
       m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
       m_connectTimer.async_wait(bind(&impl::connectTimeoutHandler, this, _1));
@@ -337,7 +337,7 @@
     if (!this->m_connectionInProgress) {
       this->m_connectionInProgress = true;
 
-      // Wait at most 4 seconds to connect
+      // Wait at most 4 time::seconds to connect
       /// @todo Decide whether this number should be configurable
       this->m_connectTimer.expires_from_now(boost::posix_time::seconds(4));
       this->m_connectTimer.async_wait(bind(&impl::connectTimeoutHandler, this, _1));
diff --git a/src/util/command-interest-generator.hpp b/src/util/command-interest-generator.hpp
index 8b4d796..18bc960 100644
--- a/src/util/command-interest-generator.hpp
+++ b/src/util/command-interest-generator.hpp
@@ -25,7 +25,7 @@
   static const Name DEFAULT_CERTIFICATE_NAME;
 
   CommandInterestGenerator()
-    : m_lastTimestamp(time::now() / 1000000)
+    : m_lastTimestamp(time::toUnixTimestamp(time::system_clock::now()))
   {
   }
 
@@ -36,30 +36,29 @@
 
   void
   generate(Interest& interest, const Name& certificateName = Name());
-  
+
   void
   generateWithIdentity(Interest& interest, const Name& identity);
-  
+
 private:
-  int64_t m_lastTimestamp;
+  time::milliseconds m_lastTimestamp;
   KeyChain m_keyChain;
 };
 
 
 inline void
-CommandInterestGenerator::generate(Interest& interest, 
+CommandInterestGenerator::generate(Interest& interest,
 				   const Name& certificateName /*= Name()*/)
 {
-  int64_t timestamp = time::now() / 1000000;
-  while(timestamp == m_lastTimestamp)
+  time::milliseconds timestamp = time::toUnixTimestamp(time::system_clock::now());
+  while(timestamp <= m_lastTimestamp)
     {
-      usleep(1000); //Guarantee unqiueness of timestamp
-      timestamp = time::now();
+      timestamp += time::milliseconds(1);
     }
 
   Name commandInterestName = interest.getName();
   commandInterestName
-    .append(name::Component::fromNumber(timestamp))
+    .append(name::Component::fromNumber(timestamp.count()))
     .append(name::Component::fromNumber(random::generateWord64()));
   interest.setName(commandInterestName);
 
@@ -70,17 +69,19 @@
 
   m_lastTimestamp = timestamp;
 }
-  
+
 inline void
 CommandInterestGenerator::generateWithIdentity(Interest& interest, const Name& identity)
 {
-  int64_t timestamp = time::now() / 1000000;
-  if(timestamp <= m_lastTimestamp)
-    timestamp = m_lastTimestamp + 1;
+  time::milliseconds timestamp = time::toUnixTimestamp(time::system_clock::now());
+  while(timestamp <= m_lastTimestamp)
+    {
+      timestamp += time::milliseconds(1);
+    }
 
   Name commandInterestName = interest.getName();
   commandInterestName
-    .append(name::Component::fromNumber(timestamp))
+    .append(name::Component::fromNumber(timestamp.count()))
     .append(name::Component::fromNumber(random::generateWord64()));
   interest.setName(commandInterestName);
 
diff --git a/src/util/command-interest-validator.hpp b/src/util/command-interest-validator.hpp
index af8c796..257f476 100644
--- a/src/util/command-interest-validator.hpp
+++ b/src/util/command-interest-validator.hpp
@@ -24,10 +24,11 @@
 
     GRACE_INTERVAL = 3000 // ms
   };
-  
-  CommandInterestValidator(int64_t graceInterval = GRACE_INTERVAL/*ms*/) 
+
+  CommandInterestValidator(const time::milliseconds& graceInterval = time::milliseconds(static_cast<int>(GRACE_INTERVAL)))
+    : m_graceInterval(graceInterval < time::milliseconds::zero() ?
+                      time::milliseconds(static_cast<int>(GRACE_INTERVAL)) : graceInterval)
   {
-    m_graceInterval = (graceInterval < 0 ? GRACE_INTERVAL : graceInterval);
   }
 
   virtual
@@ -43,26 +44,28 @@
 
 protected:
   virtual void
-  checkPolicy (const Data& data, 
-               int stepCount, 
-               const OnDataValidated &onValidated, 
+  checkPolicy (const Data& data,
+               int stepCount,
+               const OnDataValidated &onValidated,
                const OnDataValidationFailed &onValidationFailed,
                std::vector<shared_ptr<ValidationRequest> > &nextSteps)
   {
     onValidationFailed(data.shared_from_this(), "No policy for data checking");
   }
-  
+
   virtual void
-  checkPolicy (const Interest& interest, 
-               int stepCount, 
-               const OnInterestValidated &onValidated, 
+  checkPolicy (const Interest& interest,
+               int stepCount,
+               const OnInterestValidated &onValidated,
                const OnInterestValidationFailed &onValidationFailed,
                std::vector<shared_ptr<ValidationRequest> > &nextSteps);
 private:
-  int64_t m_graceInterval; //ms
+  time::milliseconds m_graceInterval; //ms
   std::map<Name, PublicKey> m_trustAnchorsForInterest;
   std::list<SecRuleSpecific> m_trustScopeForInterest;
-  std::map<Name, uint64_t> m_lastTimestamp;
+
+  typedef std::map<Name, time::system_clock::TimePoint> LastTimestampMap;
+  LastTimestampMap m_lastTimestamp;
 };
 
 inline void
@@ -82,28 +85,28 @@
 }
 
 inline void
-CommandInterestValidator::checkPolicy (const Interest& interest, 
-                                       int stepCount, 
-                                       const OnInterestValidated &onValidated, 
+CommandInterestValidator::checkPolicy (const Interest& interest,
+                                       int stepCount,
+                                       const OnInterestValidated &onValidated,
                                        const OnInterestValidationFailed &onValidationFailed,
                                        std::vector<shared_ptr<ValidationRequest> > &nextSteps)
 {
   const Name& interestName = interest.getName();
-  
-  //Prepare 
+
+  //Prepare
   if (interestName.size() < 4)
-    return onValidationFailed(interest.shared_from_this(), 
+    return onValidationFailed(interest.shared_from_this(),
                               "Interest is not signed: " + interest.getName().toUri());
-  
-  Signature signature(interestName[POS_SIG_INFO].blockFromValue(), 
+
+  Signature signature(interestName[POS_SIG_INFO].blockFromValue(),
                       interestName[POS_SIG_VALUE].blockFromValue());
-  
+
   SignatureSha256WithRsa sig(signature);
   const Name& keyLocatorName = sig.getKeyLocator().getName();
   Name keyName = IdentityCertificate::certificateNameToPublicKeyName(keyLocatorName);
-  
+
   //Check if command is in the trusted scope
-  bool inScope = false;  
+  bool inScope = false;
   for(std::list<SecRuleSpecific>::iterator scopeIt = m_trustScopeForInterest.begin();
       scopeIt != m_trustScopeForInterest.end();
       ++scopeIt)
@@ -115,23 +118,28 @@
         }
     }
   if(inScope == false)
-    return onValidationFailed(interest.shared_from_this(), 
+    return onValidationFailed(interest.shared_from_this(),
                               "Signer cannot be authorized for the command: " + keyName.toUri());
 
   //Check if timestamp is valid
-  uint64_t timestamp = interestName.get(POS_TIMESTAMP).toNumber();
-  uint64_t current = static_cast<uint64_t>(time::now()/1000000);
-  std::map<Name, uint64_t>::const_iterator timestampIt = m_lastTimestamp.find(keyName);
-  if(timestampIt == m_lastTimestamp.end())
+  time::system_clock::TimePoint interestTime = time::fromUnixTimestamp(
+                                           time::milliseconds(interestName.get(POS_TIMESTAMP).toNumber()));
+  time::system_clock::TimePoint currentTime = time::system_clock::now();
+
+  LastTimestampMap::iterator timestampIt = m_lastTimestamp.find(keyName);
+  if (timestampIt == m_lastTimestamp.end())
     {
-      if(timestamp > (current + m_graceInterval) || (timestamp + m_graceInterval) < current)
-        return onValidationFailed(interest.shared_from_this(), 
-                                  "The command is not in grace interval: " + interest.getName().toUri());
+      if (!(currentTime - m_graceInterval <= interestTime &&
+            interestTime <= currentTime + m_graceInterval))
+        {
+          return onValidationFailed(interest.shared_from_this(),
+                                    "The command is not in grace interval: " + interest.getName().toUri());
+        }
     }
-  else 
+  else
     {
-      if(m_lastTimestamp[keyName] >= timestamp)
-        return onValidationFailed(interest.shared_from_this(), 
+      if(interestTime <= timestampIt->second)
+        return onValidationFailed(interest.shared_from_this(),
                                   "The command is outdated: " + interest.getName().toUri());
     }
 
@@ -139,16 +147,22 @@
   if(!Validator::verifySignature(interestName.wireEncode().value(),
                                  interestName.wireEncode().value_size() - interestName[-1].size(),
                                  sig, m_trustAnchorsForInterest[keyName]))
-    return onValidationFailed(interest.shared_from_this(), 
+    return onValidationFailed(interest.shared_from_this(),
                               "Signature cannot be validated: " + interest.getName().toUri());
 
   //Update timestamp
-  m_lastTimestamp[keyName] = timestamp;
+  if (timestampIt == m_lastTimestamp.end())
+    {
+      m_lastTimestamp[keyName] = interestTime;
+    }
+  else
+    {
+      timestampIt->second = interestTime;
+    }
 
   return onValidated(interest.shared_from_this());
 }
 
-
 } // namespace ndn
 
 #endif // NDN_HELPERS_COMMAND_INTEREST_VALIDATOR_HPP
diff --git a/src/util/monotonic_deadline_timer.hpp b/src/util/monotonic_deadline_timer.hpp
index 3cfb05f..2b1558d 100644
--- a/src/util/monotonic_deadline_timer.hpp
+++ b/src/util/monotonic_deadline_timer.hpp
@@ -17,20 +17,20 @@
 namespace boost {
 namespace asio {
 
-template <> 
-struct time_traits<ndn::time::monotonic_clock>
+template <>
+struct time_traits<ndn::time::steady_clock::TimePoint::clock>
 {
-  typedef ndn::time::Point time_type;
-  typedef ndn::time::Duration duration_type;
+  typedef ndn::time::steady_clock::TimePoint time_type;
+  typedef ndn::time::steady_clock::TimePoint::clock::duration duration_type;
 
   static time_type
   now()
   {
-    return ndn::time::now();
+    return ndn::time::steady_clock::now();
   }
 
   static time_type
-  add(const time_type& time, const duration_type& duration) 
+  add(const time_type& time, const duration_type& duration)
   {
     return time + duration;
   }
@@ -50,13 +50,25 @@
   static boost::posix_time::time_duration
   to_posix_duration(const duration_type& duration)
   {
-    return boost::posix_time::microseconds(duration/1000);
+    return
+#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+      boost::posix_time::nanoseconds(
+        ndn::time::duration_cast<ndn::time::nanoseconds>(duration).count())
+#else
+      boost::posix_time::microseconds(
+        ndn::time::duration_cast<ndn::time::microseconds>(duration).count())
+#endif
+      ;
   }
 };
 
-typedef basic_deadline_timer<ndn::time::monotonic_clock> monotonic_deadline_timer; 
-
 } // namespace asio
 } // namespace boost
 
+namespace ndn {
+
+typedef boost::asio::basic_deadline_timer<time::steady_clock::TimePoint::clock> monotonic_deadline_timer;
+
+} // namespace ndn
+
 #endif // NDN_UTIL_MONOTONIC_DEADLINE_TIMER_HPP
diff --git a/src/util/scheduler.cpp b/src/util/scheduler.cpp
index 388d5e7..377800f 100644
--- a/src/util/scheduler.cpp
+++ b/src/util/scheduler.cpp
@@ -47,16 +47,16 @@
   bool m_isValid;
 };
 
-Scheduler::EventInfo::EventInfo(const time::Duration& after,
-                        const time::Duration& period,
-                        const Event& event)
-  : m_scheduledTime(time::now() + after)
+Scheduler::EventInfo::EventInfo(const time::nanoseconds& after,
+                                const time::nanoseconds& period,
+                                const Event& event)
+  : m_scheduledTime(time::steady_clock::now() + after)
   , m_period(period)
   , m_event(event)
 {
 }
 
-Scheduler::EventInfo::EventInfo(const time::Point& when, const EventInfo& previousEvent)
+Scheduler::EventInfo::EventInfo(const time::steady_clock::TimePoint& when, const EventInfo& previousEvent)
   : m_scheduledTime(when)
   , m_period(previousEvent.m_period)
   , m_event(previousEvent.m_event)
@@ -64,10 +64,10 @@
 {
 }
 
-time::Duration
+time::nanoseconds
 Scheduler::EventInfo::expiresFromNow() const
 {
-  time::Point now = time::now();
+  time::steady_clock::TimePoint now = time::steady_clock::now();
   if (now > m_scheduledTime)
     return time::seconds(0); // event should be scheduled ASAP
   else
@@ -84,15 +84,15 @@
 }
 
 EventId
-Scheduler::scheduleEvent(const time::Duration& after,
+Scheduler::scheduleEvent(const time::nanoseconds& after,
                          const Event& event)
 {
   return schedulePeriodicEvent(after, time::nanoseconds(-1), event);
 }
 
 EventId
-Scheduler::schedulePeriodicEvent(const time::Duration& after,
-                                 const time::Duration& period,
+Scheduler::schedulePeriodicEvent(const time::nanoseconds& after,
+                                 const time::nanoseconds& period,
                                  const Event& event)
 {
   EventQueue::iterator i = m_events.insert(EventInfo(after, period, event));
@@ -154,13 +154,13 @@
   m_isEventExecuting = true;
 
   // process all expired events
-  time::Point now = time::now();
+  time::steady_clock::TimePoint now = time::steady_clock::now();
   while(!m_events.empty() && m_events.begin()->m_scheduledTime <= now)
     {
       EventQueue::iterator head = m_events.begin();
       
       Event event = head->m_event;
-      if (head->m_period < 0)
+      if (head->m_period < time::nanoseconds::zero())
         {
           head->m_eventId->invalidate();
           m_events.erase(head);
diff --git a/src/util/scheduler.hpp b/src/util/scheduler.hpp
index 18c3004..b7364ce 100644
--- a/src/util/scheduler.hpp
+++ b/src/util/scheduler.hpp
@@ -33,7 +33,7 @@
    * \returns EventId that can be used to cancel the scheduled event
    */
   EventId
-  scheduleEvent(const time::Duration& after, const Event& event);
+  scheduleEvent(const time::nanoseconds& after, const Event& event);
 
   /**
    * \brief Schedule periodic event that should be fired every specified period.
@@ -41,8 +41,8 @@
    * \returns EventId that can be used to cancel the scheduled event
    */
   EventId
-  schedulePeriodicEvent(const time::Duration& after,
-                        const time::Duration& period,
+  schedulePeriodicEvent(const time::nanoseconds& after,
+                        const time::nanoseconds& period,
                         const Event& event);
   
   /**
@@ -60,10 +60,11 @@
 
   struct EventInfo
   {
-    EventInfo(const time::Duration& after,
-              const time::Duration& period,
+    EventInfo(const time::nanoseconds& after,
+              const time::nanoseconds& period,
               const Event& event);
-    EventInfo(const time::Point& when, const EventInfo& previousEvent);
+
+    EventInfo(const time::steady_clock::TimePoint& when, const EventInfo& previousEvent);
 
     bool
     operator <=(const EventInfo& other) const
@@ -77,11 +78,11 @@
       return this->m_scheduledTime < other.m_scheduledTime;
     }
 
-    time::Duration
+    time::nanoseconds
     expiresFromNow() const;
     
-    time::Point m_scheduledTime;
-    time::Duration m_period;
+    time::steady_clock::TimePoint m_scheduledTime;
+    time::nanoseconds m_period;
     Event m_event;
     mutable EventId m_eventId;
   };
@@ -91,7 +92,7 @@
 
   EventQueue m_events;
   EventQueue::iterator m_scheduledEvent;
-  boost::asio::monotonic_deadline_timer m_deadlineTimer;
+  monotonic_deadline_timer m_deadlineTimer;
 
   bool m_isEventExecuting;
 };
diff --git a/src/util/time.cpp b/src/util/time.cpp
deleted file mode 100644
index 07e7f34..0000000
--- a/src/util/time.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (C) 2014 Named Data Networking Project
- * See COPYING for copyright and distribution information.
- */
-
-#include "common.hpp"
-
-#include "time.hpp"
-#include <time.h>
-#include <stdexcept>
-#include <sys/time.h>
-
-namespace ndn {
-namespace time {
-
-Point
-now()
-{
-// based on suggestion from https://svn.boost.org/trac/boost/ticket/3504
-#if defined(_POSIX_TIMERS) && ( _POSIX_TIMERS > 0 ) && defined(_POSIX_MONOTONIC_CLOCK)
-
-  struct timespec t;
-  int res = clock_gettime(CLOCK_MONOTONIC, &t);
-
-  if (res == -1) {
-    throw std::runtime_error("clock_gettime");
-  }
-
-  return Point(time::seconds(t.tv_sec) + time::nanoseconds(t.tv_nsec));
-
-#else
-
-  // fallback to wall clock time
-
-  struct timeval tv;
-  int res = gettimeofday(&tv, 0);
-
-  if (res == -1) {
-    throw std::runtime_error("gettimeofday");
-  }
-
-  return Point(time::seconds(tv.tv_sec) + time::microseconds(tv.tv_usec));
-
-#endif
-}
-
-} // namespace time
-} // namespace ndn
diff --git a/src/util/time.hpp b/src/util/time.hpp
index e0b3727..afcb979 100644
--- a/src/util/time.hpp
+++ b/src/util/time.hpp
@@ -1,7 +1,5 @@
 /**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
- * @author: Yingdi Yu <yingdi@cs.ucla.edu>
+ * Copyright (C) 2013-2014 Regents of the University of California.
  * See COPYING for copyright and distribution information.
  */
 
@@ -9,228 +7,171 @@
 #define NDN_TIME_HPP
 
 #include "../common.hpp"
+#include <boost/chrono.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 
 namespace ndn {
-
-/**
- * A time interval represented as the number of milliseconds.
- */
-typedef int64_t Milliseconds;
-   
-/**
- * The calendar time represented as the number of milliseconds since 1/1/1970.
- */
-typedef int64_t MillisecondsSince1970;
-
-
-const boost::posix_time::ptime UNIX_EPOCH_TIME =
-  boost::posix_time::ptime (boost::gregorian::date (1970, boost::gregorian::Jan, 1));
-
-/**
- * @brief Get the current time in milliseconds since 1/1/1970, including fractions of a millisecond
- */
-inline MillisecondsSince1970 
-getNowMilliseconds()
-{
-  return (boost::posix_time::microsec_clock::universal_time() - UNIX_EPOCH_TIME).total_milliseconds();
-}
-
-inline MillisecondsSince1970 
-ndn_getNowMilliseconds()
-{
-  return getNowMilliseconds();
-}
-
-inline MillisecondsSince1970
-getNow()
-{
-  return getNowMilliseconds();
-}
-
-/**
- * Convert to the ISO string representation of the time.
- * @param time Milliseconds since 1/1/1970.
- * @return The ISO string.
- */
-inline std::string
-toIsoString(const MillisecondsSince1970& time)
-{
-  boost::posix_time::ptime boostTime = UNIX_EPOCH_TIME + boost::posix_time::milliseconds(time);
-
-  /// @todo Determine whether this is necessary at all
-  if ((time % 1000) == 0)
-    return boost::posix_time::to_iso_string(boostTime) + ".000000"; 
-  else
-    return boost::posix_time::to_iso_string(boostTime);
-}
-  
-/**
- * Convert from the ISO string representation to the internal time format.
- * @param isoString The ISO time formatted string. 
- * @return The time in milliseconds since 1/1/1970.
- */
-inline MillisecondsSince1970
-fromIsoString(const std::string& isoString)
-{
-  boost::posix_time::ptime boostTime = boost::posix_time::from_iso_string(isoString);
-  
-  return (boostTime-UNIX_EPOCH_TIME).total_milliseconds();
-}
-
 namespace time {
 
-class monotonic_clock;
+using boost::chrono::duration;
 
-/** \class Duration
- *  \brief represents a time interval
- *  Time unit is nanosecond.
+typedef duration<boost::int_least32_t, boost::ratio<86400> > days;
+using boost::chrono::hours;
+using boost::chrono::minutes;
+using boost::chrono::seconds;
+
+using boost::chrono::milliseconds;
+using boost::chrono::microseconds;
+using boost::chrono::nanoseconds;
+
+using boost::chrono::duration_cast;
+
+/**
+ * \brief System clock
+ *
+ * System clock represents the system-wide real time wall clock.
+ *
+ * It may not be monotonic: on most systems, the system time can be
+ * adjusted at any moment. It is the only clock that has the ability
+ * to be displayed and converted to/from UNIX timestamp.
+ *
+ * To get current TimePoint:
+ *
+ * <code>
+ *     system_clock::TimePoint now = system_clock::now();
+ * </code>
+ *
+ * To convert TimePoint to/from UNIX timestamp:
+ *
+ * <code>
+ *     system_clock::TimePoint time = ...;
+ *     uint64_t timestampInMilliseconds = toUnixTimestamp(time).count();
+ *     system_clock::TimePoint time2 = fromUnixTimestamp(time::milliseconds(timestampInMilliseconds));
+ * </code>
  */
-class Duration
+class system_clock : public boost::chrono::system_clock
 {
 public:
-  Duration()
-    : m_value(0)
-  {
-  }
+  typedef time_point TimePoint;
+  typedef duration Duration;
 
-  explicit
-  Duration(int64_t value)
-    : m_value(value)
-  {
-  }
-  
-  operator int64_t&()
-  {
-    return m_value;
-  }
+  // /// \brief Get current TimePoint
+  // TimePoint
+  // now();
+}; // class system_clock
 
-  operator const int64_t&() const
-  {
-    return m_value;
-  }
-
-  Duration
-  operator+(const Duration& other) const
-  {
-    return Duration(this->m_value + other.m_value);
-  }
-  
-  Duration
-  operator-(const Duration& other) const
-  {
-    return Duration(this->m_value - other.m_value);
-  }
-
-private:
-  int64_t m_value;
-};
-
-/** \class Point
- *  \brief represents a point in time
- *  This uses monotonic clock.
+/**
+ * \brief Steady clock
+ *
+ * Steady clock represents a monotonic clock. The time points of this
+ * clock cannot decrease as physical time moves forward. This clock is
+ * not related to wall clock time, and is best suitable for measuring
+ * intervals.
+ *
+ * Note that on OS X platform this defaults to system clock and is not
+ * truly monotonic. Refer to https://svn.boost.org/trac/boost/ticket/7719)
  */
-class Point
+class steady_clock : public
+#ifdef __APPLE__
+// steady_clock may go backwards on OS X platforms, so use system_clock
+// instead
+    boost::chrono::system_clock
+#else
+    boost::chrono::steady_clock
+#endif
 {
 public:
-  Point()
-    : m_value(0)
-  {
-  }
+  typedef time_point TimePoint;
+  typedef duration Duration;
 
-  explicit
-  Point(int64_t value)
-    : m_value(value)
-  {
-  }
-  
-  operator int64_t&()
-  {
-    return m_value;
-  }
+  // /// \brief Get current TimePoint
+  // TimePoint
+  // now();
+}; // class steady_clock
 
-  operator const int64_t&() const
-  {
-    return m_value;
-  }
 
-  Point
-  operator+(const Duration& other) const
-  {
-    return Point(this->m_value + static_cast<int64_t>(other));
-  }
-  
-  Duration
-  operator-(const Point& other) const
-  {
-    return Duration(this->m_value - other.m_value);
-  }
-
-  Point
-  operator-(const Duration& other) const
-  {
-    return Point(this->m_value  - static_cast<int64_t>(other));
-  }
-  
-private:
-  int64_t m_value;
-};
-
-inline std::ostream&
-operator<<(std::ostream &os, const Duration& duration)
+/**
+ * \brief Get system_clock::TimePoint representing UNIX time epoch (00:00:00 on Jan 1, 1970)
+ */
+inline const system_clock::TimePoint&
+getUnixEpoch()
 {
-  os << static_cast<int64_t>(duration) / 1000000000.0 << " s";
-  return os;
+  static system_clock::TimePoint epoch = system_clock::from_time_t(0);
+  return epoch;
 }
 
 /**
- * \brief Get current time
- * \return{ the current time in monotonic clock }
+ * \brief Convert system_clock::TimePoint to UNIX timestamp
  */
-Point
-now();
-
-/**
- * \brief Get time::Duration for the specified number of seconds
- */
-template<class T>
-inline Duration
-seconds(T value)
+inline milliseconds
+toUnixTimestamp(const system_clock::TimePoint& point)
 {
-  return Duration(value * static_cast<int64_t>(1000000000));
+  return duration_cast<milliseconds>(point - getUnixEpoch());
 }
 
 /**
- * \brief Get time::Duration for the specified number of milliseconds
+ * \brief Convert UNIX timestamp to system_clock::TimePoint
  */
-template<class T>
-inline Duration
-milliseconds(T value)
+inline system_clock::TimePoint
+fromUnixTimestamp(const milliseconds& duration)
 {
-  return Duration(value * static_cast<int64_t>(1000000));
+  return getUnixEpoch() + duration;
 }
 
 /**
- * \brief Get time::Duration for the specified number of microseconds
+ * \brief Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff)
+ *
+ * If timePoint contains doesn't contain fractional seconds the
+ * output format is YYYYMMDDTHHMMSS
+ *
+ * Examples:
+ *
+ *   - with fractional nanoseconds:  20020131T100001,123456789
+ *   - with fractional microseconds: 20020131T100001,123456
+ *   - with fractional milliseconds: 20020131T100001,123
+ *   - without fractional seconds:   20020131T100001
  */
-template<class T>
-inline Duration
-microseconds(T value)
+inline std::string
+toIsoString(const system_clock::TimePoint& timePoint)
 {
-  return Duration(value * static_cast<int64_t>(1000));
+  boost::posix_time::ptime ptime = boost::posix_time::from_time_t(
+                                     system_clock::TimePoint::clock::to_time_t(timePoint));
+
+  uint64_t micro = duration_cast<microseconds>(timePoint - getUnixEpoch()).count() % 1000000;
+  if (micro > 0)
+    {
+      ptime += boost::posix_time::microseconds(micro);
+      return boost::posix_time::to_iso_string(ptime);
+    }
+  else
+    return boost::posix_time::to_iso_string(ptime);
 }
 
 /**
- * \brief Get time::Duration for the specified number of nanoseconds
+ * \brief Convert from the ISO string (YYYYMMDDTHHMMSS,fffffffff) representation
+ *        to the internal time format
+ *
+ * Examples of accepted ISO strings:
+ *
+ *   - with fractional nanoseconds:  20020131T100001,123456789
+ *   - with fractional microseconds: 20020131T100001,123456
+ *   - with fractional milliseconds: 20020131T100001,123
+ *   - without fractional seconds:   20020131T100001
+ *
  */
-inline Duration
-nanoseconds(int64_t value)
+inline system_clock::TimePoint
+fromIsoString(const std::string& isoString)
 {
-  return Duration(value);
-}
+  static boost::posix_time::ptime posixTimeEpoch = boost::posix_time::from_time_t(0);
 
+  boost::posix_time::ptime ptime = boost::posix_time::from_iso_string(isoString);
+
+  system_clock::TimePoint point = system_clock::from_time_t((ptime - posixTimeEpoch).total_seconds());
+  point += microseconds((ptime - posixTimeEpoch).total_microseconds() % 1000000);
+  return point;
+}
 
 } // namespace time
-
 } // namespace ndn
 
 #endif // NDN_TIME_HPP
