date-format

Javascript convert yyyy-mm-dd hh:mm:ss like newDate(“day, month date year hh:mm:ss”)

前提是你 提交于 2019-12-21 22:41:27
问题 I want to use Date Object Methods ( getHoures(), getSeconds() ...) on new Date("string") (string = month day, year hh:mm:ss ) but my date format is like this : yyyy-mm-dd hh:mm:ss So I need to convert "yyyy-mm-dd hh:mm:ss" to "( "day, month date year hh:mm:ss" )" How can i do please ? Thx ! 回答1: Actually, you don't need to perform any such conversion. The string you have is already in very nearly an acceptable format for new Date(string) and in fact even as is will be accepted by most (if not

NSDateFormatter returns null for specific dates

霸气de小男生 提交于 2019-12-21 12:37:41
问题 I'm having a problem with the NSDateFormatter . It is returning null for some specific dates. I did this function to debug the case: - (void) debugTest:(NSString *)dateStr{ NSLog(@"String: %@", dateStr); NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy-MM-dd"]; NSDate *dateObj = [df dateFromString: dateStr]; NSLog(@"Date: %@", dateObj); } This is my log output for some dates: String: 2012-10-18 Date: 2012-10-18 03:00:00 +0000 String: 2012-10-19 Date: 2012-10-19

NSDateFormatter returns null for specific dates

浪子不回头ぞ 提交于 2019-12-21 12:35:14
问题 I'm having a problem with the NSDateFormatter . It is returning null for some specific dates. I did this function to debug the case: - (void) debugTest:(NSString *)dateStr{ NSLog(@"String: %@", dateStr); NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy-MM-dd"]; NSDate *dateObj = [df dateFromString: dateStr]; NSLog(@"Date: %@", dateObj); } This is my log output for some dates: String: 2012-10-18 Date: 2012-10-18 03:00:00 +0000 String: 2012-10-19 Date: 2012-10-19

System date formatting not using django locale

爷,独闯天下 提交于 2019-12-21 07:09:54
问题 Trying to understand L10N implementation into Django, Here are my settings LANGUAGE_CODE = 'fr-FR' USE_L10N = True If I try >>> datetime.datetime.strptime('2012-05-30 15:30', '%Y-%m-%d %H:%M') .strftime('%c') It will give me 'Wed May 30 15:30:00 2012' that is the EN locale. However the doc is saying: [...] Two users accessing the same content, but in different language, will see date and number fields formatted in different ways, depending on the format for their current locale [...] Are they

How to convert String date to Date?

空扰寡人 提交于 2019-12-20 07:48:33
问题 I have done following code: String str = "2013-01-17 11:26"; DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:MM"); Date date = dateFormat.parse(str); System.out.println("str :"+str); System.out.println("Date :"+date); Output str :21-01-2013 11:26 Date :Sat Feb 21 11:01:00 IST 2015 But something is wrong. I expect out as same as string date. i.e. Thu Jan 21 11:26:00 IST 2013 回答1: You are using the wrong format. MM is for month , and mm is for minutes , and for hours use HH . See

java does not parse for 'M dd, yyyy' date format

跟風遠走 提交于 2019-12-20 07:32:05
问题 I want to parse date strings like "February 7, 2011" using "M dd, yyyy" format. But I get an exception. 回答1: Your parsing string is not correct as mentioned by others To correctly parse February you need to use an english Locale or it may fail if your default Locale is not in English DateFormat df = new SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH); Date dt = df.parse("February 7, 2011"); 回答2: Try this code. I ran it with two dates "November 20, 2012" and "January 4, 1957" and got this

How to get Date format like this in android?

假装没事ソ 提交于 2019-12-20 07:14:35
问题 How to get Date format like this? Saturday,Dec 11,2011 Edited: My code portion is like the following: String outDate = ""; Date dT = new Date(year, mon, day); SimpleDateFormat sdf = new SimpleDateFormat("EEE,MMM dd,yyyy"); outDate = sdf.format(dT); and its output is `Sat,Dec 02,3911` when year = 2011,mon = 11,day = 2; what is the reason of giving wrong month and year in output? 回答1: You can use SimpleDateFormat. Try: SimpleDateFormat formatter = new SimpleDateFormat("EEEE,MMM dd,yyyy");

Manipulating dates in Javascript without the Date object

旧巷老猫 提交于 2019-12-20 05:14:33
问题 It appears I can't use the javascript Date object as it inherintly defaults to US dates when you initialise with a datestring. There is no way of passing any culture information to the date object I.e. No matter what the clients locale settings are var d = new Date("08/10/2009") will always create a date object representing the 10th August 2009 rather than the 8th October 2009 if the clients locale was the UK. So given that my requirement is to be able to add/subtract days/months/years easily

sqlite change date format of every cell in column

做~自己de王妃 提交于 2019-12-20 05:11:31
问题 I have a table with a large number of rows. One column contains dates in the format '%m/%d/%Y' and I want to change all of them to format '%Y-%m-%d' the usual: update table set mydate = '6' doesn't work I guess because the date is always changing. How would I do that in this case? 回答1: If the fields in the date string are properly padded with zeros, you can extract them as substrings: UPDATE MyTable SET MyDate = substr(MyDate, 7, 4) || '-' || substr(MyDate, 1, 2) || '-' || substr(MyDate, 4, 2

getting java.lang.IllegalArgumentException: Illegal pattern character 'o'? while parsing java.text.SimpleDateFormat

∥☆過路亽.° 提交于 2019-12-20 01:57:10
问题 I wanted to convert from string to java.util.Date. for the same purpose I used following code, String timeStamp = "Mon Feb 14 18:15:39 IST 2011"; DateFormat formatter = new SimpleDateFormat("dow mon dd hh:mm:ss zzz yyyy"); Date ts = (Date)formatter.parse(timeStamp); The format given to SimpleDateFormat() is format of java.util.Date. When you convert util's Date to string it comes in this format('dow mon dd hh:mm:ss zzz yyyy'). But when I execute code, It gives me Exception. I Don't know what