From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

number of seconds since midnight

Solved!
Go to solution

Time Stamp.  Front Panel under numeric control

Quotient Remainder.  Block diagram under numeric

To DBL.  Block Diagram under numeric >> conversion

0 Kudos
Message 11 of 28
(1,152 Views)

@psuedonym wrote:

Sorry.

I mean the solution by crossrulz.

I am not understanding how that solution works because it looks like I have to manually enter today's midnight.

???


His solution works by dividing the current time (Time is stored internally as number of seconds elapsed since the Epoch) by the number of seconds in one day.

 

The remainder is the number of seconds elapsed since midnight of the current day.

 

That is as I said BRILLIANT!

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 12 of 28
(1,147 Views)

3:00:00.000 pm ====>  68400  using the VI

 

15 hours x 3600 seconds / hour = 54000

 

???

0 Kudos
Message 13 of 28
(1,143 Views)

@psuedonym wrote:

Don't I need to input the current midnight using this method?

Unless I am not understanding this.


No, you do not need to compute the number of seconds as midnight.  What my code does is divide the number of seconds since the epoch (Midnight on January 1, 1904, UTC) by the number of seconds in a day.  So the Quotient will be the number of days since 1904.  The remainder will be the seconds since today started (UTC time).

 

I just used a Timestamp Control (in the Numeric palette) as an input to prove the algorithm.  You can use the Get Date/Time In Seconds to use the current time.  Attached is a more complete VI that I would use if I was doing it for myself.  I saved it in LabVIEW 8.0.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 14 of 28
(1,142 Views)

@psuedonym wrote:

3:00:00.000 pm ====>  68400  using the VI

 

15 hours x 3600 seconds / hour = 54000

 

???


 You are exactly 4 hours off, which I would guess is due to a timezone setting.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 15 of 28
(1,136 Views)

@crossrulz wrote:

A simple Quotient & Remainder will do the trick...


Wouldn't that be off by 27 seconds as of now?

And would gradually get worse?

 

Leap seconds being the cause of the error?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 16 of 28
(1,136 Views)

@psuedonym wrote:

3:00:00.000 pm ====>  68400  using the VI

 

15 hours x 3600 seconds / hour = 54000

 

???


There is a quote out there that goes something like "If you don't hate time zones, you're not a real programmer".  The timestamp is based on UTC time.  You are apparently in EDT (Eastern Daylight Time).  You can somehow pass in the time zone, compute the offset yourself, or just only use UTC.  Due to my current work, I just stick with UTC (lots of GPS).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 17 of 28
(1,132 Views)

FYI: Use the function instead of a Control.

image.png

 

The Remainder/Quotiant is found in the Numeric menu.

 

image.png

 

EDIT: Apparently I am way too slow and missed the whole second page! LOL

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 18 of 28
(1,129 Views)

Thanks all.

 

I will use the more convoluted way of calculating since I don't have to worry about which time zone is running the VI. I did find https://forums.ni.com/t5/Example-Programs/Convert-a-time-stamp-from-UTC-to-Locale-and-back/ta-p/3505... which discusses converting UTC to local.

 

 

Message 19 of 28
(1,111 Views)
Solution
Accepted by topic author psuedonym

I love crossrulz's solution, but have to adjust for current timezone.  Or just do this.

seconds today.png

Message 20 of 28
(1,108 Views)