datetime-format

Globalization of CultureInfo & DateTimeFormatInfo: How can we change digits format to my language?

我的梦境 提交于 2019-12-11 05:49:23
问题 I use System.Globalization like below: CultureInfo calture = new CultureInfo(MyCultureInfoGoesHere); DateTimeFormatInfo info = calture.DateTimeFormat; info.AbbreviatedDayNames = new string[] { "bla", "bla", "bla", "bla", "bla", "bla", "bla" }; info.ShortestDayNames = new string[] { "bla", "bla", "bla", "bla", "bla", "bla", "bla" }; info.DayNames = new string[] { "bla", "bla", "bla", "bla", "bla", "bla", "bla" }; info.AbbreviatedMonthNames = new string[] { "bla", "bla", "bla", "bla", "bla",

Detecting if user has entered date, time or datetime

别说谁变了你拦得住时间么 提交于 2019-12-11 04:56:00
问题 I have an input field in which users can either enter the following: Datetime: DD-MMM-YY HH:mm:ss.SSS Date: DD-MMM-YY Time: HH:mm:ss I am trying to determine which of the above 3 a user has entered, for example: var timeInput = $scope.userDatetime; var timeOnly = moment(timeInput, "HH:mm:ss").isValid(); The above can tell me if a user has entered a time only, but can i determine if they have entered a date only or date and time? Additionally, looking at the moment docs, i can see the above

Have a list of hours between two dates in python

感情迁移 提交于 2019-12-11 04:48:11
问题 I have two times and I want to make a list of all the hours between them using the same format in Python from= '2016-12-02T11:00:00.000Z' to= '2017-06-06T07:00:00.000Z' hours=to-from so the result will be something like this 2016-12-02T11:00:00.000Z 2016-12-02T12:00:00.000Z 2016-12-02T13:00:00.000Z ..... and so on How can I so this and what kind of plugin should I use? 回答1: If possible I would recommend using pandas. import pandas time_range = pandas.date_range('2016-12-02T11:00:00.000Z',

How can I convert a string in the format “YYYYMM” to “MMMYY”?

谁说我不能喝 提交于 2019-12-11 04:33:14
问题 I want to pass values in YYYYMM format such as "201509" to a function and retrieve the human-friendlier "MMMYY" format, such as "Sep 2015". I thought this might work: internal static string GetMMMYYFromYYYYMM(String YYYYMMVal) { string intermediateStr = YYYYMMVal + "01"; DateTime intermediateDate = Convert.ToDateTime(intermediateStr); return intermediateDate.ToString("MMMyy"); } ...but no, it crashes with " String was not recognized as a valid DateTime " ISTM that the YYYYMMDD format should

Inconsistency in java date library for week of year

走远了吗. 提交于 2019-12-11 04:24:52
问题 As per https://en.wikipedia.org/wiki/ISO_8601#Week_dates, Weekdays start on Monday. But, from Java, if you try to extract week number in two different ways, two different outputs come if the date is a Sunday. import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class TestDate { public static void main(String[] args) throws ParseException { final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); final SimpleDateFormat

Specify datetime format for WCF Data Service

最后都变了- 提交于 2019-12-11 03:08:21
问题 Is there a way to specify the formatting of DateTime data returned by a WCF data service? This question seems to say that the default format, which looks like /Date(1339515455030)/ , is the number of milliseconds since midnight Januery 1, 1970 UTC. I can figure out how to parse that if I have to but I'd rather specify a more friendly format. 回答1: The OData DateTime format (assuming you haven't already formatted it out to a string) is dependent on the wire format negotiated between client and

Date Time create from format

人盡茶涼 提交于 2019-12-11 02:24:51
问题 I want to create date with specific format for e.g 03-20-2010 have a format of m-d-Y but date function do not understand this date and returns wrong date $date = date("Y-m-d", strtotime("03-20-2010")); Above code is returning wrong date, what is the reason behind it and how to avoid wrong result? Few formats that I want date function to recognize are "Y/m/d" , "m/d/Y" , "F d, Y" , "M d, Y". 回答1: strtotime won't recognize an American style ordering separated by '-', but if you use a '/'

Spring: How do I set the pattern of a @DateTimeFormat from a properties file?

China☆狼群 提交于 2019-12-11 00:13:23
问题 I'm using Spring 3.1.1.RELEASE. I have a model that I submit to one of my controllers. In it, is the following field @DateTimeFormat(pattern = "#{appProps['class.date.format']}") private java.util.Date startDate; However, the above doesn't work (the EL isn't being interpreted), in as far as every time I submit my form, I get an error. If I use the following @DateTimeFormat(pattern="yyyy-MM-dd") private java.util.Date startDate; everything works fine. But ideally, I'd like to drive the pattern

mysql query to get age 25/04 months format where date format is 1988-04-04?

青春壹個敷衍的年華 提交于 2019-12-10 22:15:28
问题 I have date field in mysql in 1988-04-04 format.I need to calculate age in 25/04 months format.I tried this: SELECT CONCAT( FLOOR((curdate() - dob) / 31536000), 'y ', FLOOR(MOD((curdate() - dob) / 31536000 * 12, 12)), 'm' ) `age` from age It is giving me 0/0 months. I'll be grateful for any help. 回答1: When you select curdate() in a numeric context, you get the yyyymmdd value, such as 20130812 (for today, August 12, 2013). That's not really that useful for date calculations. By way of example,

sas datetime to R date format

我的梦境 提交于 2019-12-10 21:42:50
问题 I have a SAS dataset containing a datetime variable. I have ported this dataset into R using the sas7bdat package but the datetime variable is shown in integer number format (e.g. 1706835972). Is there any way to convert this integer into a date format? 回答1: To match exactly what SAS outputs for default datetime structure, you need to use as.POSIXct as was mentioned in comments, and additionally use the tz=UTC argument: sasDateTimes <- c(1706835972, 1716835972, 1726835972, 1736835972,