Getting milliseconds on a time stamp

I have been searching all afternoon to no avail. I can use a process to get the current time in seconds from the epoch:

Process date;
...
    if (!date.running()) {
    date.begin("date");
    date.addParameter("+%s%N");
    date.run();
  }
...
date.readString();

That only gives seconds. If I use:

      date.addParameter("+%s::%N");

I get seconds with "::%N" appended to the end.

I SSH'd into the Yun and tried:

date +"%s%N"

I get:

1507587542%N

I installed opkg install coreutils-date

Same result.
I rebooted, same result.

I need to get the timestamp that has the number of seconds from the epoch with milliseconds:

1507587542.873

How?

I need to get the timestamp that has the number of seconds from the epoch with milliseconds:

The date/time functions are accurate to the nearest second. You can NOT get milliseconds from the number of seconds since 1/1/1970 (or 1/1/2000).

Hmmm. What are you using to set it to that degree of accuracy?

aarg:
Hmmm. What are you using to set it to that degree of accuracy?

OP isn't asking for something that crazy/unreasonable.

Javascript's Date.now() returns number of milliseconds since 1970...

BulldogLowell:
OP isn't asking for something that crazy/unreasonable.

Javascript's Date.now() returns number of milliseconds since 1970...

Does Javascript return Date.now() with milliseconds on a Yun?

Also, I don't really know how the clocks work but I am not really asking for millisecond since 1970, I am asking for the time to not be rounded to the second. I am asking for a partial second value be returned. This is very standard on Linux.

Here it is from a webserver:

~ >> date
Wed Oct 11 18:01:35 CDT 2017
~ >> date +%s
1507762903
~ >> date +%s.%N
1507762910.309654000

In fact, every Linux I have ever SSL'd into gives the same resolution.

I just can't get the partial second from the Yun.

Even more interesting...The top post on this forum is:

Using millis() for timing. A beginners guide

Hmmm...Seems that SOMETHING can get milliseconds. A Yun can get a timestamp from a time server.

flycast:
Does Javascript return Date.now() with milliseconds on a Yun?

Also, I don't really know how the clocks work but I am not really asking for millisecond since 1970, I am asking for the time to not be rounded to the second. I am asking for a partial second value be returned. This is very standard on Linux.

Here it is from a webserver:

~ >> date
Wed Oct 11 18:01:35 CDT 2017
~ >> date +%s
1507762903
~ >> date +%s.%N
1507762910.309654000

In fact, every Linux I have ever SSL'd into gives the same resolution.

I just can't get the partial second from the Yun.

you need fractions of a second, which the standard Javascript analogy I mentioned provides.

you have a Yun... use an NTP server, no problem...

this issue may be a time library for yun that uses that resolution.

BulldogLowell:
OP isn't asking for something that crazy/unreasonable.

But just because the software will dutifully deliver time in milliseconds doesn't mean the time has been synced properly. That is my point. I wasn't asking what it was needed for, there are many applications. GPS will get you much closer than SNTP if you are hoping for actual millisecond accuracy.

Perhaps my question should have been, exactly how much accuracy do you require?

I would like millisecond resolution. As for accuracy...I am OK with the accuracy being off 1/10th of a second or more. I want as much accuracy as the Yun can muster. I am using the time value as a key in a database. THe database cannot use identical keys. If you enter a new value with an identical key then the database will update the existing record with the new data. So:

I am looking to get a time stamp as close as reasonably possible
A Unique number as a key

Then just use the time to the second and whatever value millis() mod 1000 gives you. Or else cast the result of millis() to an int - in which case it will still never yield the same value in the same second.

Yes. I was aware of that work around and have been thinking about that from the beginning. I could just append a random number on the end of the seconds as well, that's not far from what you propose. I guess my thought is that is a pretty rough workaround for a standard function that Linux has (time) and that the Yun (for whatever reason) doesn't implement. With that said...plus, Yun has the "added advantage" of being able to use the bridge and execute linux functions to get said timestamp.

I think the inability to get fractions od seconds from the Linux processor is a bug. Is there a place where one can do a bug report for the Yun in the hopes that it can get resolved on the next release?

flycast:
Yes. I was aware of that work around and have been thinking about that from the beginning. I could just append a random number on the end of the seconds as well, that's not far from what you propose.

Not really, as there is a small but definite possibility of duplication with a random number.

flycast:
I think the inability to get fractions od seconds from the Linux processor is a bug. Is there a place where one can do a bug report for the Yun in the hopes that it can get resolved on the next release?

It's not a bug. It's an unimplemented feature. Part of the reason Linux can run on so many platforms is that it is modular. You can't expect all features to be present in all kernels/shells. Especially in an embedded release.

Wellllll, let me phrase the question differently then. How to request that it be implemented in the next release?

flycast:
Wellllll, let me phrase the question differently then. How to request that it be implemented in the next release?

Open an issue here:

...or make the change yourself and build a new image