Save dates with hours with 12-hour format in mongo with c #

1

I have a date but when I save it mongoDb puts me the time of the date in 24 hours or military time format.

Example:

The date is this {6/04/2017 3:03:00 p. m.} and it keeps it that way {2017-04-06 15:03:00.000}

What do I do to save it in the format it comes in?

    
asked by lARAPRO 12.10.2018 в 19:00
source

1 answer

1

You will have to change the server configuration with respect to the date / time format.

To make it simpler, I recommend changing in the presentation layer.

If you're doing web development, go to the momentJS

library.
moment().format('MMMM Do YYYY, h:mm:ss a'); // October 12th 2018, 10:27:00 am
moment().format('dddd');                    // Friday
moment().format("MMM Do YY");               // Oct 12th 18
moment().format('YYYY [escaped] YYYY');     // 2018 escaped 2018
moment().format();                          // 2018-10-12T10:27:00-07:00

If you're with C #

// Display using current (en-us) culture's short date format
DateTime thisDate = new DateTime(2008, 3, 15);
Console.WriteLine(thisDate.ToString("d"));           // Displays 3/15/2008

Here you can find more details:

link

    
answered by 12.10.2018 в 19:35