GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Micro/milliseconds since epoch
Operating System - HP-UX
1849583
Members
6792
Online
104044
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2004 07:45 PM
05-24-2004 07:45 PM
Hi all
I'm looking for a utility or script that will return milliseconds or preferably microseconds from epoch until present, or until a specific date.
On mainframes, we had "dateandtimeinmicroseconds", but I know nothing like that exists on standard HP-UX.
I'm looking for a utility or script that will return milliseconds or preferably microseconds from epoch until present, or until a specific date.
On mainframes, we had "dateandtimeinmicroseconds", but I know nothing like that exists on standard HP-UX.
Trying is the first step to failure - Homer Simpson
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2004 08:26 PM
05-24-2004 08:26 PM
Re: Micro/milliseconds since epoch
You don't have a utility as such but there is the 'C' gettimeofday() function.
Here is a bare bones example of how you might use it. Beware, I haven't actually tried to compile this :)
#include
main(){
struct timeval t;
struct timezone tz;
gettimeofday(&t,&tz);
printf("Time in seconds is %ld and %ld micro-seconds\n",t.tv_sec,t.tv_usec);
}
Here is a bare bones example of how you might use it. Beware, I haven't actually tried to compile this :)
#include
main(){
struct timeval t;
struct timezone tz;
gettimeofday(&t,&tz);
printf("Time in seconds is %ld and %ld micro-seconds\n",t.tv_sec,t.tv_usec);
}
Never preceed any demonstration with anything more predictive than "watch this"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2004 08:31 PM
05-25-2004 08:31 PM
Solution
See also the thread http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=602110
#include
struct timeval now;
struct timezone timezone;
gettimeofday(&now,&timezone);
/* now.tv_sec is seconds since EPOCH
(1/1/1970 00:00:00) */
/* now.tv_usec is microseconds in the current second */
do a man on "gettimeofday" and have a look in the time.h include file for more info and details of the structures.
Note: Microseconds are not always accurate to the microsecond - there is some small error involved in the CPU calculating this. However, it would be insignificant in the calculation of milliseconds from microseconds. This error can be significant in calculation of timestamps for things like auditing software or flight simulations etc.
Enjoy
Rossco
#include
struct timeval now;
struct timezone timezone;
gettimeofday(&now,&timezone);
/* now.tv_sec is seconds since EPOCH
(1/1/1970 00:00:00) */
/* now.tv_usec is microseconds in the current second */
do a man on "gettimeofday" and have a look in the time.h include file for more info and details of the structures.
Note: Microseconds are not always accurate to the microsecond - there is some small error involved in the CPU calculating this. However, it would be insignificant in the calculation of milliseconds from microseconds. This error can be significant in calculation of timestamps for things like auditing software or flight simulations etc.
Enjoy
Rossco
Everything should be made as simple as possible, but not simpler. Albert Einstein.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP