question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSR based date value calculation

See original GitHub issue

SSR based date value calculation

This is kind of similar to https://github.com/ndresx/react-countdown/issues/42 issue but I couldn’t make it work via now prop.

@ndresx I want to pass down the current time from the server instead of Date.now() that can be anything based on the user settings. When I add the same timestamp to the now prop, the countdown stops.

The date prop calculates the countdown time based on the Date.new(), is there away I can pass down the current date from the server instead of Date.now()

If I do this, even if the user has an invalid date on their browser, I would still be able to show the right time on the countdown.

any idea?

// Todo: Calculate current time based on the server. Client side can't be valid all the times.

<Countdown
  key="countdown"
  date={targetTime} // or an option here would make it even easier
  now={() => ServerSideCurrentTImeInTimeStamp} // SSR current date
  renderer={renderer}
/>

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ndresxcommented, Dec 18, 2022

Hi, you would have to calculate the difference between Date.now() and ServerSideCurrentTImeInTimeStamp, and then basically say that now equals Date.now() + this difference. now is called every second, so the value it returns needs to be a dynamic value, not a static one.

0reactions
noor-codescommented, Dec 23, 2022

Thank You, I’ll give it a shot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSRS Calculate duration between two dates - Stack Overflow
I'm getting a run time error in expression - conversion from string "29/01/2015 14:00" to type 'Date' is not valid. · I took...
Read more >
Calculate Value based on Days in Month - MSDN - Microsoft
I am looking to calculate budget values based on days in a month. ... multiply the result by the number of days in...
Read more >
SSRS Report Builder Part 7.6 - Calculating Date Parts
By Andrew GouldIf you'd like to help fund Wise Owl's conversion of tea and biscuits into quality training videos, you can click this...
Read more >
What is SSRS DateDiff? - eduCBA
In SSRS reports, calculate the number of days for just a case that is produced for a specific problem type/case subtype that is...
Read more >
SSRS Commonly Required Date Expressions - Devin Knight
Argument, Description ; Interval, This is the interval you want to add (Ex. Days, Months, Years…) ; Number, Numeric value that represents the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found