datetime-format

Format date-time as seasons in R?

与世无争的帅哥 提交于 2019-12-17 14:45:59
问题 In R, it's possible to format POSIXlt date-time objects as a month: format(Sys.time(), format='%Y-%m') Is there a way to do the same thing with seasons, or 3-month groups (DJF, MAM, JJA, SON)? These divisions are really common in climatological and ecological science, and it would be great to have a neat way to format them quickly like with months. Obviously DJF falls over 2 years, but for the purposes or this question, that doesn't really matter - just consistently shove them into either

Format datetime in asp.net mvc 4

夙愿已清 提交于 2019-12-17 02:34:17
问题 How can I force the format of datetime in asp.net mvc 4 ? In display mode it shows as I want but in edit model it doesn't. I am using displayfor and editorfor and applyformatineditmode=true with dataformatstring="{0:dd/MM/yyyy}" What I have tried: globalization in web.config (both of them) with my culture and uiculture. modifying the culture and uiculture in application_start() custom modelbinder for datetime I have no idea how to force it and I need to input the date as dd/MM/yyyy not the

Unable to obtain LocalDateTime from TemporalAccessor when parsing LocalDateTime (Java 8)

时间秒杀一切 提交于 2019-12-17 02:34:11
问题 I am simply trying to convert a date string into a DateTime object in Java 8. Upon running the following lines: DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); LocalDateTime dt = LocalDateTime.parse("20140218", formatter); I get the following error: Exception in thread "main" java.time.format.DateTimeParseException: Text '20140218' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2014-02-18 of type java.time.format.Parsed at

Change datetime format to Y-m-d, but the datetime is like 7/12/17 6:20:39 pm [duplicate]

扶醉桌前 提交于 2019-12-14 04:26:48
问题 This question already has answers here : Converting string to Date and DateTime (9 answers) Convert a date format in PHP (16 answers) Convert one date format into another in PHP (15 answers) Should I use the datetime or timestamp data type in MySQL? (37 answers) Closed last year . EDIT : I need to change this datetime into Y-m-d H:i:s format from dd/mm/yy H:i:s format. This is for PHP or CodeIgniter project. I got some data from other report not formatted well. datetime 7/12/17 12:15:23 pm

How do I convert DateTime to another format?

送分小仙女□ 提交于 2019-12-14 03:25:10
问题 From a weather feed I'm getting the data for dates in the form of 2012-05-17 . How do I convert that to Thursday May 17th form? 回答1: Parse the string into a JavaScript Date object. Format the Date object however you like. See also: Why does Date.parse give incorrect results? and How to format a JavaScript date questions. 回答2: How about this: var originalDateTime = '2012-05-17', splitedDatetime = originalDateTime.split('0'), date = new Date(), date.setFullYear(splitedDatetime[0]

get calculated date cell in PHPExcel

牧云@^-^@ 提交于 2019-12-14 02:26:28
问题 I used PHPExcle to import an excel file. I found I could not get correct value from a calculated cell. The calculated value is 8月27日 (a date in Chinese) in that cell, it means 27 August in English. The cell references to A1 in Sheet2, and A1 in Sheet2 references to a cell in another excel file. I've already tried some ways as below: echo $cell->getValue(); // =Sheet2!A2 echo $cell->__toString(); // =Sheet2!A2 echo $cell->getCalculatedValue(); // #REF! echo $cell->getFormattedValue(); // #REF!

Format date in mongodb query output on shell

£可爱£侵袭症+ 提交于 2019-12-14 00:58:46
问题 I want to format the date time into an specific format on the mongo shell output My query db.getCollection('people').find({ date: { $gte: ISODate("2017-04-24T14:04:34.447Z") } }, { _id: 0, age: 0, } ); My output against this query: /* 1 */ { "user_id" : "bcd020", "status" : "D", "date" : ISODate("2017-04-24T14:04:34.447Z") } /* 2 */ { "user_id" : "bcd021", "status" : "D", "date" : ISODate("2017-04-24T14:04:34.447Z") } What i want is to format the datetime in the output something like, /* 1 */

How To Convert Data Format with Chinese words (下午/上午) In T-SQL Script with C# (based on SQL Server with Chinese Version)

不羁岁月 提交于 2019-12-13 16:35:37
问题 I have a problem with SqlCommand in C#, I need to insert DateTime format to SQL Server like as following code For example using (SqlConnection conn = new SqlConnection("Data Source=127.0.0.1;Initial Catalog=B2CCompareData;Persist Security Info=True;User ID=sa;Password=1111;MultipleActiveResultSets=True;Connection Timeout=600; Application Name=EntityFramework")) { conn.Open(); SqlCommand cmd = conn.CreateCommand(); try { cmd.CommandText = "Insert into table1(indexid,createTime) values(1

Use variable in re.sub, for Python parsing multiple datetime-format strings?

本小妞迷上赌 提交于 2019-12-13 15:22:56
问题 I'm trying to come up with a function to translate various human date/time-format strings to Python compatible ones (from '*yyyy-MMM-dd*' to '*%Y-%b-%d*' ). So far I built the translate dictionary below (a list of tuples [('yyyy','%Y'),('MMM','%b'),...] ) so I can convert placeholder fields in input format-strings into strptime '%x' fields e.g.: 'yyyy-MMM-dd' --> '{5}-{3}-{12}' But what do I do next? I've tried multiple ways: >>> re.sub('({\d+})',translateList['\1'][1],'{5}-{3}-{12}')

How Convert.ToDateTime() parses a given string when the given culture does not know the format

落爺英雄遲暮 提交于 2019-12-13 14:31:56
问题 I have the following code, and it works. string testDateStr = "2009.7.28 05:23:15"; DateTime testDateObj = Convert.ToDateTime(testDateStr, CultureInfo.GetCultureInfo("fr-FR")); And I checked the valid formats for my culture: string[] validFormats = testDateObj.GetDateTimeFormats(CultureInfo.GetCultureInfo("fr-FR")); And none of them matches the "2009.7.28 05:23:15" format. I want to know how this is parsed without throwing a format exception, and what kind of hidden parsing is done when we