datetime-format

Is DateTime.parse() in Ruby dependent on locale?

拟墨画扇 提交于 2019-12-22 18:01:06
问题 I'm wondering regarding the output of the following example: when parsing 01/03 , will it be resolved as Mar, 1st or Jan, 3rd ? 回答1: Ruby is not locale dependent. Because Ruby is a server-side language and not a client-side language like JavaScript, Ruby uses the system clock from your web app server - and uses this information to calculate the time. Whatever timezone you have your system set to is what your Ruby app will use. When parsing a date from a string, DateTime will make its best

DateTime::format and strftime

末鹿安然 提交于 2019-12-22 10:40:02
问题 I have $date = $run['at']; which gives me 2013-06-03T16:52:24Z (from a JSON input). To transform it to get for example " d M Y, H:i " I use $date = new DateTime($run['at']); echo $date->format('d M Y, H:i'); Problem is I need the date in italian. And the only function that supports set_locale is strftime . How can I "wrap" DateTime::format with strftime (or replace, dunno)? 回答1: setlocale(LC_TIME, 'it_IT.UTF-8'); $date = new DateTime($run['at']); strftime("%d %B", $date->getTimestamp()) ...

Convert UTC Date to datetime string Titanium

房东的猫 提交于 2019-12-22 09:57:35
问题 I have a date string "2012-11-14T06:57:36+0000" that I want to convert to the following format "Nov 14 2012 12:27" . I have tried a lot of solutions including Convert UTC Date to datetime string Javascript. But nothing could help me. The following code worked for me in android. But for ios it displays as invalid date var date = "2012-11-14T06:57:36+0000"; //Calling the function date = FormatDate(date); //Function to format the date function FormatDate(date) { var newDate = new Date(date);

How to format JSON date?

一世执手 提交于 2019-12-22 08:11:10
问题 so, i need format JSON date from this format "9/30/2010 12:00:00 AM", it is MM/DD/YYYY HH:MM:SS to format like this : DD/MM/YYYY , so i dont need info about hours, min and sec, and i need replace months and days from json, i tried some different ways but it always failed i need do this using jQuery also i didnt find any answer to formating this date type, all i found was formating date like this : /Date(1224043200000)/ so anyone have idea? 回答1: you can create a Date Object from a string like

Complement [FromUri] serialization with APIController

佐手、 提交于 2019-12-22 07:57:57
问题 We have multiple API controllers accepting GET requests like so: //FooController public IHttpActionResult Get([FromUri]Foo f); //BarController public IHttpActionResult Get([FromUri]Bar b); Now - we would like (or, are forced) to change DateTime string format within GET query string globally "yyyy-MM-ddTHH:mm:ss" -> "yyyy-MM-ddTHH.mm.ss" After the change all [FromUri] serializations with classes containing DateTime types fail. Is there a way to complement [FromUri] serialization to accept the

Formatting a Date as words in Rails

无人久伴 提交于 2019-12-22 03:59:07
问题 So I have a model instance that has a datetime attribute. I am displaying it in my view using: <%= @instance.date.to_date %> but it shows up as: 2011-09-09 I want it to show up as: September 9th, 2011 How do I do this? Thanks! 回答1: <%= @instance.date.strftime("%B %d, %Y") %> This would give you "September 9, 2011". If you really needed the ordinal on the day ("th", "rd", etc.), you could do: <%= @instance.date.strftime("%B #{@instance.date.day.ordinalize}, %Y") %> 回答2: There is an easier

How to convert getTime() to 'YYYY-MM-DD HH24:MI:SS' [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-12-20 07:48:16
问题 This question already has answers here : Convert timestamp in milliseconds to string formatted time in Java (9 answers) Closed 2 years ago . I Have the following code in my application System.out.println(rec.getDateTrami().getTime()); I need to convert the following format (I suppose that they are seconds) 43782000 29382000 29382000 To a format YYYY-MM-DD HH24:MI:SS , anyone can help to me? 回答1: You can make use of the SimpleDateFormat Example: SimpleDateFormat format = new SimpleDateFormat(

Format a date String java

我只是一个虾纸丫 提交于 2019-12-20 07:17:34
问题 I have a date String like so :- Fri Oct 31 11:30:58 GMT+05:30 2014 I want to Convert it into 2014-10-31T6:00:00 which should be after adding the offset. How can I do it? 回答1: First you need a SimpleDateFormat with the pattern that matches your input String: "EEE MMM dd HH:mm:ss z yyyy" . Take a look at: SimpleDateFromat API SimpleDateFormat in = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy"); Then you can parse the input String to get a corresponding Date object as follows: Date date = in

How to get day, month, year and hour, minutes, second from DateTime format?

孤者浪人 提交于 2019-12-20 06:54:07
问题 I tried this following code but its a deprecated in android SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); try { Date date1 = simpleDateFormat.parse("11/20/2014 8:10:00 AM"); Log.e("date", "" + date1.getYear()); Log.e("month", "" + date1.getmonth()); Log.e("year", "" + date1.getYear()); Log.e("hour", "" + date1.getHours()); Log.e("minutes", "" + date1.getMinutes()); Log.e("seconds", "" + date1.getSeconds()); } catch (ParseException e) { // TODO Auto-generated

Setting default DateTimeFormat Annotation in Spring

心已入冬 提交于 2019-12-20 05:53:30
问题 I know that a DateTimeFormat annotation can be defined on Date properties of a Model class in Spring but is there any way of defining a default dateTimeFormat annotation for all Dates in Spring Model classes? @DateTimeFormat(pattern = "MM/dd/YYYY") private Date deliveryDate; It will save me from annotating each date field. It will also make it easy for me to change the application wide date format later on. 回答1: As kuhajeyan mentioned, you can use binder, but not on a controller, rather on