datetime-format

DateTime issue when global culture of the server is different on different servers

懵懂的女人 提交于 2019-11-27 06:09:41
问题 My website is hosted on multiple servers at different locations Everywhere the Culture of the data format is different- we use mm/dd/yyyy format every where but incase some server has the culture set to dd/mm/yyyy then our website generates Datetime exception. 回答1: You should be specifying what culture you want to use whenever you convert a string to a date. The culture you should be using depends on what culture the dates are formatted as. For example, if all dates you are parsing are

Converting Double to DateTime?

ε祈祈猫儿з 提交于 2019-11-27 06:05:32
问题 I have a .CSV file which I am reading into a C# program. In one of the columns, there is a date, but it is in the "general" format, so it shows up in the .CSV as a number. For example: 41172. How can I convert this number to a date with format dd/mm/yyyy in C#? 41172 is equivalent to 20/09/2012. 回答1: EDIT: As noted in comments and other answers, DateTime.FromOADate is a much better approach. I'll remove this answer if it's ever unaccepted. (But, there are still platforms like .NET Core where

Unable to obtain ZonedDateTime from TemporalAccessor using DateTimeFormatter and ZonedDateTime in Java 8

拥有回忆 提交于 2019-11-27 04:57:47
I recently moved to Java 8 to, hopefully, deal with local and zoned times more easily. However, I'm facing an, in my opinion, simple problem when parsing a simple date. public static ZonedDateTime convertirAFecha(String fecha) throws Exception { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( ConstantesFechas.FORMATO_DIA).withZone( obtenerZonaHorariaServidor()); ZonedDateTime resultado = ZonedDateTime.parse(fecha, formatter); return resultado; } In my case: fecha is '15/06/2014' ConstantesFechas.FORMATO_DIA is 'dd/MM/yyyy' obtenerZonaHorariaServidor returns ZoneId.systemDefault() So

convert epoch time to date

假装没事ソ 提交于 2019-11-27 01:44:22
I've tried a million different ways of doing this, but with no avail. Any help would be much appreciated. long millis = getMillisFromServer(); Date date = new Date(millis); DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("Australia/Sydney")); String formatted = format.format(date); The above doesn't work. basically, what I want to do is, get the epoch time and convert it to Australian time. My local time is +05.30 but of course I don't want this to be a factor which contributes to this conversion. EDIT- Output when I run your exact code,

Creating graph with date and time in axis labels with matplotlib

别等时光非礼了梦想. 提交于 2019-11-27 00:22:44
I have my data in an array of the following structure, [[1293606162197, 0, 0], [1293605477994, 63, 0], [1293605478057, 0, 0], [1293605478072, 2735, 1249], [1293606162213, 0, 0], [1293606162229, 0, 0]] The first column is epoch time (in ms ), second is y1 and third is y2 . I need a plot with the time on the x-axis, and y1 and y2 on left and right y-axes. I have been scouring through the documentation but couldn't find any way to get my x-axis ticks to display both date and time, like "28/12 16:48", i.e., "date/month hour:min". All the documentation helps me with is to display dates alone, but

How to convert datetime in persian in sql server

烈酒焚心 提交于 2019-11-26 22:58:54
I want to convert my datetime into persian datetime in sql server. My datetime is in MM/DD/YYYY format. Is there any function in sql server to do this as when i want hijri datetime i use this select CONVERT(VARCHAR(40), getdate(), 131) //Output is 14/08/1432 5:02:01:197PM I'm using sql server 2008 Saman Gholami I know it is too late for answering this question, but I've submitted the function that I'm using for a long time without any bug, all of other methods which I've ever seen have problem with intercalary years: CREATE FUNCTION [CalculatePersianDate] ( @intDate DATETIME ) RETURNS NVARCHAR

date format function to display date as “Jan 13 2014”

若如初见. 提交于 2019-11-26 22:10:52
问题 Is there any function to display date in the format mmm-dd-yyyy in VBScript? eg. today's date as Jan 22 2014 ? I tried using function FormatDateTime(Now(), 2) I got it as 16 January 2014 . Is there any function/format to get it as Jan 16 2014 ? 回答1: By using a .NET Stringbuilder - for all your formatting needs - you get the most bang for the buck: Option Explicit Class cFormat Private m_oSB Private Sub Class_Initialize() Set m_oSB = CreateObject("System.Text.StringBuilder") End Sub ' Class

How to parse a UTC offset dateformat string into the resulting date separated by | symbol

随声附和 提交于 2019-11-26 22:06:27
问题 I have a very peculiar question where I am trying to parse "2019-12-25T17:00:00-05:00" such that it should give me the result DEC 12 | Thursday | 5:00pm I tried the following code by using DateTimeFormatter and LocalDate DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssz", Locale.US); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("MM d | E | hh:mm a", Locale.US); LocalDate date = LocalDate.parse("2019-12-25T17:00:00-05:00", inputFormatter)

How do I get the AM/PM value from a DateTime?

隐身守侯 提交于 2019-11-26 21:57:24
The code in question is below: public static string ChangePersianDate(DateTime dateTime) { System.Globalization.GregorianCalendar PC = new System.Globalization.GregorianCalendar(); PC.CalendarType = System.Globalization.GregorianCalendarTypes.USEnglish; return PC.GetYear(dateTime).ToString() + "/" + PC.GetMonth(dateTime).ToString() + "/" + PC.GetDayOfMonth(dateTime).ToString() + "" + PC.GetHour(dateTime).ToString() + ":" + PC.GetMinute(dateTime).ToString() + ":" + PC.GetSecond(dateTime).ToString() + " " ???????????????? } how can I get the AM/PM from the dateTime value? How about: dateTime

How do I convert datetime to ISO 8601 in PHP

久未见 提交于 2019-11-26 21:38:19
How do I convert my time from 2010-12-30 23:21:46 to ISO 8601 date format? (-_-;) alex Object Oriented This is the recommended way. $datetime = new DateTime('2010-12-30 23:21:46'); echo $datetime->format(DateTime::ATOM); // Updated ISO8601 Procedural For older versions of PHP, or if you are more comfortable with procedural code. echo date(DATE_ISO8601, strtotime('2010-12-30 23:21:46')); After PHP 5 you can use this: echo date("c"); form ISO 8601 formatted datetime. http://ideone.com/nD7piL Note for comments: Regarding to this , both of these expressions are valid for timezone, for basic format