Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Time in milliseconds
Time in milliseconds [message #45819] Sun, 10 January 2016 23:26 Go to next message
forlano is currently offline  forlano
Messages: 1064
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

do we have a way to get the current local time in millisecond?
I need a timestamp.

Thanks,
Luigi
Re: Time in milliseconds [message #45822 is a reply to message #45819] Mon, 11 January 2016 09:32 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 196
Registered: July 2011
Location: Bangalore
Experienced Member
Actually milliseconds is part of

typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;

Use
	SYSTEMTIME systime;
	GetLocalTime(&systime);


Warm Regards

Deepak
Re: Time in milliseconds [message #45825 is a reply to message #45822] Mon, 11 January 2016 09:49 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1064
Registered: March 2006
Location: Italy
Experienced Contributor
Great!
Thanks,
Luigi
Re: Time in milliseconds [message #45834 is a reply to message #45825] Mon, 11 January 2016 15:09 Go to previous messageGo to next message
ManfredHerr is currently offline  ManfredHerr
Messages: 67
Registered: February 2013
Location: Germany
Member
1. This is a windows solution only
2. Some say that the resolution is poor, i.e. 66msecs interval the same time stamp.
If you need better resolution and portability please consider Didier's offering in the forum:
high resolution TimeStop code [message #44393]
Re: Time in milliseconds [message #45883 is a reply to message #45834] Tue, 19 January 2016 16:39 Go to previous message
Mindtraveller is currently offline  Mindtraveller
Messages: 916
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

As long as U++ moves to C++11, you may try something like
#include <chrono>

using namespace std::chrono;

int main() {
  auto now = system_clock::now();
  time_point<system_clock> epoch;
  microseconds ms = duration_cast<milliseconds>(now - epoch);
  microseconds hs = std::chrono::hours(1);
}
Previous Topic: Critical section in PteBase::PtrAdd
Next Topic: [solved] Why doesn't Vector have Find?
Goto Forum:
  


Current Time: Sun Sep 22 07:51:25 CEST 2019

Total time taken to generate the page: 0.01325 seconds