date-format

Convert ISO 8601 to unixtimestamp

不想你离开。 提交于 2019-11-29 04:51:40
问题 How can I convert 2012-01-18T11:45:00+01:00 (ISO 8601) to 1326883500 (unixtimestamp) in PHP? 回答1: echo date("U",strtotime('2012-01-18T11:45:00+01:00')); 回答2: To convert from ISO 8601 to unixtimestamp : strtotime('2012-01-18T11:45:00+01:00'); // Output : 1326883500 To convert from unixtimestamp to ISO 8601 (timezone server) : date_format(date_timestamp_set(new DateTime(), 1326883500), 'c'); // Output : 2012-01-18T11:45:00+01:00 To convert from unixtimestamp to ISO 8601 (GMT) : date_format(date

updating a date format in mysql

ぐ巨炮叔叔 提交于 2019-11-29 04:51:35
I am working on a table that has two formats of dates stored in a field some are in mm/dd/yy and the newer entries are in yyyy/mm/dd like they should be. I want to run an query like this UPDATE table SET date_field = DATE_FORMAT(date_field, '%Y/%m/%d') WHERE date_field = DATE_FORMAT(date_field, '%m/%d/%y') But it is just not working out. One result that I got was that it was just taking the %m data and turning it into the %Y and really messing up the data. Any thoughts? You want to use STR_TO_DATE function, not DATE_FORMAT. Plus, I assume you only want to update the misformed dates, so I guess

Going from MM/DD/YYYY to DD-MMM-YYYY in java

江枫思渺然 提交于 2019-11-29 03:59:15
Is there a method in Java that I can use to convert MM/DD/YYYY to DD-MMM-YYYY ? For example: 05/01/1999 to 01-MAY-99 Thanks! Use a SimpleDateFormat to parse the date and then print it out with a SimpleDateFormat withe the desired format. Here's some code: SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy"); Date date = format1.parse("05/01/1999"); System.out.println(format2.format(date)); Output: 01-May-99 Try this, Date currDate = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); String strCurrDate =

Compare dates in DataView.RowFilter?

我是研究僧i 提交于 2019-11-29 03:46:51
I am scratching my head over something rather stupid yet apparently difficult. DataView dvFormula = dsFormula.Tables[0].DefaultView; dvFormula.RowFilter = "'" + startDate.ToString("yyyyMMdd") + "' < EndDate OR EndDate = '19000101'"; dvFormula.Sort = "FromDate ASC"; The result is this: Cannot perform '<' operation on System.String and System.DateTime. Please tell me what the best way to solve this problem would be. Much appreciated! Dan You need to wrap your dates with #, not apostrophes. dvFormula.RowFilter = "#" + startDate.ToString("MM/dd/yyyy") + "# < EndDate OR EndDate = #1/1/1900#"; Darsh

Parsing a date with short month without dot

荒凉一梦 提交于 2019-11-29 03:37:51
I have a String that represents a date in French locale : 09-oct-08 : I need to parse that String so I came up with this SimpleDateFormat : String format2 = "dd-MMM-yy"; But I have a problem with the month part, that seems to be expected with a ending dot : df2.format(new Date()); gives me : 28-oct.-09 What is now the best way for me to make SimpleDateFormat understand ("09-oct-08") ? Full Code : String format2 = "dd-MMM-yy"; DateFormat df2 = new SimpleDateFormat(format2,Locale.FRENCH); date = df2.parse("09-oct-08"); This gives me : java.text.ParseException: Unparseable date: "09-oct-08" And

dd/mm/yyyy vs dd/MM/yyyy?

回眸只為那壹抹淺笑 提交于 2019-11-29 02:44:42
问题 SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); String date = sdf.format(new Date()); System.out.println(date); Result is todays date i.e 23/03/2014 But when i do SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy"); result can be 23/05/2014, 23/05/2014, 23/06/2014 and son with each run of prgram. Why so? 回答1: As we can see from the documentation, it's because mm is for minutes, not months. 回答2: 1. d/D: day without 0 prefix on single digit. 2. dd/DD: day with 0 prefix if

How to change date format using jQuery?

为君一笑 提交于 2019-11-28 23:32:14
I have a date in a format like this fecha2.value = '2014-01-06' , but I want to change the format to this '01-06-14' using jQuery. How can I do this? Thanks in advance. You can use date.js to achieve this: var date = new Date('2014-01-06'); var newDate = date.toString('dd-MM-yy'); Alternatively, you can do it natively like this: var dateAr = '2014-01-06'.split('-'); var newDate = dateAr[1] + '-' + dateAr[2] + '-' + dateAr[0].slice(-2); console.log(newDate); I dont think you need to use jQuery at all, just simple JavaScript... Save the date as a string: dte = fecha.value;//2014-01-06 Split the

ActiveRecord date format

我与影子孤独终老i 提交于 2019-11-28 23:21:31
I've run into a spot of bother with date formats in our Rails application. I have a date field in our view which I want to be formatted as dd/mm/yy . This is how the user will expect to enter their dates, and the datepicker control uses this format. However, Active Record seems to be expecting mm/dd/yy . If I enter 01/03/2010 , this gets put in as 03 January 2010 . If I enter 25/03/2010 , this gets put in a null . How do I get ActiveRecord to expect Her Majesties date format? Rails' DateTime tries to detect the formatting automatically. It will detect the following formats: mm/dd/yy or dd-mm

AngularJS - How do you convert milliseconds to xHours and yMins

余生颓废 提交于 2019-11-28 21:20:46
I've a requirement where I want to convert milliseconds to xHours and yMins in AngularJS. For ex. 3600000 should be displayed as 1h 0m. I tried using date:'H:m' and date:'HH:mm' from the date formats on Angular's website. But those give 19:0 and 19:00 instead of 1h 0m. Any pointers of achieving this will be helpful. Thanks haotang Let make a custom filter for this, e.g: .filter('millSecondsToTimeString', function() { return function(millseconds) { var oneSecond = 1000; var oneMinute = oneSecond * 60; var oneHour = oneMinute * 60; var oneDay = oneHour * 24; var seconds = Math.floor((millseconds

Convert a string to Date format in XSLT

醉酒当歌 提交于 2019-11-28 20:50:47
I have a date(string) value in an XML file in this format: Tue Apr 17 03:12:47 IST 2012 I want to use XSL transformation to convert the string/date into this format: 4/17/2012 03:12:47 AM How can I do that in my XSL transform? If you are using XSLT 1.0 version, use EXSLT - date:format-date date extension XSLT 2.0 version, use built-in: Formatting Dates and Times date extension But my suggestion is to Have a standard XSD datetime format on XML, on the code-behind (that is, on rendering time) you can format as you like. Update: Always XML to process through XSLT, dates should be in standard XSD