How to get a Long Date format from DateTime without a weekday
String formattedDate = DateTime.Now.Date.ToLongDateString().Replace(DateTime.Now.DayOfWeek.ToString()+ “, “, “”)
String formattedDate = DateTime.Now.Date.ToLongDateString().Replace(DateTime.Now.DayOfWeek.ToString()+ “, “, “”)
In case you’re restricted to legacy java.util.Date and java.util.Calendar APIs, you need to take into account that the timestamps are interpreted in milliseconds, not seconds. So you first need to multiply it by 1000 to get the timestamp in milliseconds. long seconds = 1320105600; long millis = seconds * 1000; This way you can feed … Read more
Compiling information from standard date and time format strings: Pattern Example Short Date Pattern (“d”) MM/dd/yyyy Long Date Pattern (“D”) dddd, dd MMMM yyyy Full Date Short Time (“f”) dddd, dd MMMM yyyy HH:mm Full Date Long Time (“F”) dddd, dd MMMM yyyy HH:mm:ss General Date Short Time (“g”) MM/dd/yyyy HH:mm General Date Long Time … Read more
You’ll need to use the pytz module (available from PyPI): import pytz from datetime import datetime est = pytz.timezone(‘US/Eastern’) utc = pytz.utc fmt=”%Y-%m-%d %H:%M:%S %Z%z” winter = datetime(2016, 1, 24, 18, 0, 0, tzinfo=utc) summer = datetime(2016, 7, 24, 18, 0, 0, tzinfo=utc) print(winter.strftime(fmt)) print(summer.strftime(fmt)) print(winter.astimezone(est).strftime(fmt)) print(summer.astimezone(est).strftime(fmt)) which will print: 2016-01-24 18:00:00 UTC+0000 2016-07-24 18:00:00 … Read more
New answer for old question. Rationale: updated tools. Using this free, open source library, one can parse into a std::chrono::time_point<system_clock, milliseconds>, which has the advantage over a tm of being able to hold millisecond precision. And if you really need to, you can continue on to the C API via system_clock::to_time_t (losing the milliseconds along … Read more
That extra .000 is micro seconds. This will convert a date string of a format to datetime object. import datetime d1 = datetime.datetime.strptime(“2013-07-12T07:00:00Z”,”%Y-%m-%dT%H:%M:%SZ”) d2 = datetime.datetime.strptime(“2013-07-10T11:00:00.000Z”,”%Y-%m-%dT%H:%M:%S.%fZ”) Then convert them into any format depending on your requirement, by using: new_format = “%Y-%m-%d” d1.strftime(new_format)
MyNewDateValue = MyDateNow.AddDays(-MyDateInteger);
Best method in SQL Server 2016 Example: SELECT FORMAT(GETDATE(), ‘yyyy/MM/dd-HH:mm:ss’, ‘fa’) Answer: 1398/10/08-05:37:59
OK, I looked at the the source code and it’s pretty straightforward: DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendInstant(3).toFormatter(); I hope it works for all scenarios, and it can help someone else. Don’t hesitate to add a better/cleaner answer. Just to explain where it comes from, in the JDK’s code, ISO_INSTANT is defined like this: public static … Read more