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.

Datetime parsed to localTime.

See original GitHub issue

While passing DateTime object to DataTablesResult.Create method it is parsed to UTC time zone. In order to change it I had to include your whole project to my solution just to change:

static StringTransformers()
{
     RegisterFilter<DateTimeOffset>(dateTimeOffset => dateTimeOffset.ToLocalTime().ToString("g"));
     RegisterFilter<DateTime>(dateTime => dateTime.ToLocalTime().ToString("g"));
}

to:

static StringTransformers()
{
     RegisterFilter<DateTimeOffset>(dateTimeOffset => dateTimeOffset.ToString("g"));
     RegisterFilter<DateTime>(dateTime => dateTime.ToString("g"));
}

Is there any better way to do that? I’d like to display exactly this date which is stored in my database. Thanks for any tips.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Sarogatipcommented, Jul 26, 2016

It works very well. Thank you very much.

1reaction
mcintyre321commented, Jul 26, 2016

I haven’t had a chance to test this, but you should be able to do this:


protected void Application_Start(object sender, EventArgs e) {
{
     StringTransformers.RegisterFilter<DateTimeOffset>(dateTimeOffset => dateTimeOffset.ToString("g"));
     StringTransformers.RegisterFilter<DateTime>(dateTime => dateTime.ToString("g"));
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parse date time c# with correct timezone and kind
Generally, the Parse method returns a DateTime object whose Kind ... to the time in the local time zone and the Kind is...
Read more >
DateTime.Parse Method (System) - Microsoft Learn
The Parse method tries to convert the string representation of a date and time value to its DateTime equivalent. It tries to parse...
Read more >
LocalTime parse() method in Java with Examples
In LocalTime class, there are two types of parse() method ... The string must have a valid date-time and is parsed using DateTimeFormatter....
Read more >
Java Date Time - LocalTime.parse() Examples - LogicBig
public static LocalTime parse(CharSequence text). Returns the LocalTime instance for the provided text. The text must be valid per DateTimeFormatter.
Read more >
How to Convert String to LocalDateTime in Java 8 - Java67
parse () method. It takes a String and a DateTimeFormatter as a parameter. The DateTimeFormatter argument is used to specify the date/time pattern....
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