datetime-format

Correct insert DateTime from c# to mongodb

流过昼夜 提交于 2019-11-30 05:19:32
I try to insert local time in MongoDB var time = DateTime.Now; // 03.05.2014 18:30:30 var query = new QueryDocument { { "time", nowTime} }; collection3.Insert(query); But in database I see ISODate("2014-05-03T15:30:30.170Z") , that must be ISODate("2014-05-03T18:30:30.300Z") . Please help me! I think you're getting confused by time zones. The Z at the end of the string indicates that it's in UTC. When you posted this question, it was just after 15:30 UTC. I strongly suspect that the correct instant in time is being recorded - but it's being recorded as an instant in time without reference to a

“asp-format” not applied to tag helpers

跟風遠走 提交于 2019-11-30 04:49:01
I'm facing a problem using "asp-format" tag with taghelper element in my mvc 6 project. The idea is to format a date input element this way: <input asp-for="StartDate" asp-format="{0:dd/MM/yyyy}" /> This "StartDate" property is in my model, declared this way: public DateTime StartDate {get; set; } For a strange reason, this element is never formatted, and is presented always like this: ---> 02/29/2016 00:00:00 So I created a viewmodel class and defined a property to hold the entire person model. public class PersonViewModel { public Person Johndoe {get; set; } } And using this class in the

Formatting date in Thymeleaf

故事扮演 提交于 2019-11-30 01:17:14
I'm brand new to Java/Spring/Thymeleaf so please bear with my current level of understanding. I did review this similar question , but wasn't able to solve my problem. I'm trying to get a simplified date instead of the long date format. // DateTimeFormat annotation on the method that's calling the DB to get date. @DateTimeFormat(pattern="dd-MMM-YYYY") public Date getReleaseDate() { return releaseDate; } ​ html: <table> <tr th:each="sprint : ${sprints}"> <td th:text="${sprint.name}"></td> <td th:text="${sprint.releaseDate}"></td> </tr> </table> Current output sprint1 2016-10-04 14:10:42.183

ISO 8601 date-time format combining 'Z' and offset of '+0000'

隐身守侯 提交于 2019-11-29 23:39:55
问题 I'm playing with date-time format from ISO 8601. I have this pattern: "yyyy-MM-dd'T'HH:mm:ssZZ'Z'" and the output is: "2015-11-17T00:00:00+0000Z" . My question is if the output is ok, if is possible to have in a date +0000 and Z taking in account both has the same meaning time zone offset/id. Thanks in advance for clarification =) 回答1: No, not OK No, the Z is an offset-from-UTC so it should not be combined redundantly with a numerical offset of +00:00 or +0000 . ISO 8601 While I do not have

How to get an isoformat datetime string including the default timezone?

时光毁灭记忆、已成空白 提交于 2019-11-29 21:15:24
I need to produce a time string that matches the iso format yyyy-mm-ddThh:mm:ss.ssssss-ZO:NE . The now() and utcnow() class methods almost do what I want. >>> import datetime >>> #time adjusted for current timezone >>> datetime.datetime.now().isoformat() '2010-08-03T03:00:00.000000' >>> #unadjusted UTC time >>> datetime.datetime.utcnow().isoformat() '2010-08-03T10:00:00.000000' >>> >>> #How can I do this? >>> datetime.datetime.magic() '2010-08-03T10:00:00.000000-07:00' Something like the following example. Note I'm in Eastern Australia (UTC + 10 hours at the moment). >>> import datetime >>>

Convert number of seconds into HH:MM (without seconds) in Java

血红的双手。 提交于 2019-11-29 17:39:48
I'm aware that you can use DateUtils.formatElapsedTime(seconds) to convert a number of seconds into a String with the format HH:MM:SS . But are there any utility functions that let me perform the same conversion but without the seconds? For example, I want to convert 3665 seconds into 1:01 , even though it's exactly 1:01:05 . In other words, simply dropping the seconds part. Would strongly prefer an answer that points to a utility function (if one exists) rather than a bunch of home rolled algorithms. Based on the available information, you seem to be wanting to format a duration based value.

How to Change Date Format in .net RDLC Report?

元气小坏坏 提交于 2019-11-29 17:04:05
问题 I need to set my date column as 01-Jan-2013 , what is the format to acheieve this in rdlc? I have given =CDate(Fields!IssuingDate.Value).ToString("dd-mmm-yyyy") its not working correctly. Any one post me the format for 02-Jul-2013 . 回答1: Use this you will get your output =CDate(Fields!IssuingDate.Value).ToString("dd-MMM-yyyy") 回答2: Possibility 1: I think the correct format string is "dd-MMM-yyyy" ( uppercase M , see MSDN) And I would use Format(Fields!IssuingDate.Value,"dd-MMM-yyyy") instead

.NET Date to string gives invalid strings in Vista Pseudo-cultures

末鹿安然 提交于 2019-11-29 16:26:01
问题 My computer is configured with a culture that is not en-US. When using the native Win32 GetDateFormat function, i get correctly formatted dates: 22//11//2011 4::42::53 P̰̃M] This is correct; and is also how Windows renders it: the taskbar Region and Language settings Windows Explorer Outlook When i try to convert a date to a string in .NET using my current locale, e.g.: DateTime.Now.ToString(); DateTime.Now.ToString(CultureInfo.CurrentCulture); i get an incorrect date: 22////11////2011 4:::

How to fast convert different time formats in large data frames?

怎甘沉沦 提交于 2019-11-29 16:16:37
I want to calculate length in different time dimensions but I have problems dealing with the two slightly different time formats in my data frame column. The original data frame column has about a million rows with the two formats (shown in the example code) mixed up . Example code: time <- c("2018-07-29T15:02:05Z", "2018-07-29T14:46:57Z", "2018-10-04T12:13:41.333Z", "2018-10-04T12:13:45.479Z") length <- c(15.8, 132.1, 12.5, 33.2) df <- data.frame(time, length) df$time <- format(as.POSIXlt(strptime(df$time,"%Y-%m-%dT%H:%M:%SZ", tz=""))) df The formats "2018-10-04T12:13:41.333Z" and "2018-10

How can I visualize the way various DateTime formats will display?

半腔热情 提交于 2019-11-29 15:34:08
问题 I want to be able to quickly reference how various DateTime formats will appear, rather than embark upon a laborious process of edit, compile, gawk, and recurse until satisfied. 回答1: This shows all the formats for the current culture: StringBuilder sb = new StringBuilder(); foreach (string dateTimePattern in DateTimeFormatInfo.CurrentInfo.GetAllDateTimePatterns()) { sb.AppendFormat("{0} = {1}\r\n", dateTimePattern, DateTime.Now.ToString(dateTimePattern)); } StringBuilder contents after: M/d