Questions tagged [datetime-format]

datetime-format is a transformation of a timestamp from an industry standard format, such as UTC or ISO, to a format which conforms to the standards of a particular locale or audience

APIs to handle datetime-format operations are part of many programming languages. Here are some of the most common:

3123 questions
1501
votes
39 answers

Where can I find documentation on formatting a date in JavaScript?

I noticed that JavaScript's new Date() function is very smart in accepting dates in several formats. Xmas95 = new Date("25 Dec, 1995 23:15:00") Xmas95 = new Date("2009 06 12,12:52:39") Xmas95 = new Date("20 09 2006,12:52:39") I could not find…
Naga Kiran
  • 8,585
  • 5
  • 43
  • 53
1113
votes
53 answers

Format JavaScript date as yyyy-mm-dd

I have a date with the format Sun May 11,2014. How can I convert it to 2014-05-11 using JavaScript? function taskDate(dateMilli) { var d = (new Date(dateMilli) + '').split(' '); d[2] = d[2] + ','; return [d[0], d[1], d[2],…
user3625547
  • 11,159
  • 3
  • 12
  • 6
1012
votes
19 answers

Given a DateTime object, how do I get an ISO 8601 date in string format?

Given: DateTime.UtcNow How do I get a string which represents the same value in an ISO 8601-compliant format? Note that ISO 8601 defines a number of similar formats. The specific format I am looking for is: yyyy-MM-ddTHH:mm:ssZ
Iain
  • 12,269
  • 6
  • 24
  • 13
552
votes
16 answers

Python datetime to string without microsecond component

I'm adding UTC time strings to Bitbucket API responses that currently only contain Amsterdam (!) time strings. For consistency with the UTC time strings returned elsewhere, the desired format is 2011-11-03 11:07:04 (followed by +00:00, but that's…
davidchambers
  • 23,918
  • 16
  • 76
  • 105
467
votes
6 answers

Convert DataFrame column type from string to datetime

How can I convert a DataFrame column of strings (in dd/mm/yyyy format) to datetime dtype?
perigee
  • 9,438
  • 11
  • 31
  • 35
352
votes
7 answers

UnsupportedTemporalTypeException when formatting Instant to String

I'm trying to format an Instant to a String using the new Java 8 Date and Time API and the following pattern: Instant instant = ...; String out = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(instant); Using the code above I get an…
Dag
  • 10,079
  • 8
  • 51
  • 74
251
votes
15 answers

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

The code in question is below: public static string ChangePersianDate(DateTime dateTime) { System.Globalization.GregorianCalendar PC = new System.Globalization.GregorianCalendar(); PC.CalendarType =…
SilverLight
  • 19,668
  • 65
  • 192
  • 300
241
votes
13 answers

Unable to obtain LocalDateTime from TemporalAccessor when parsing LocalDateTime (Java 8)

I am simply trying to convert a date string into a DateTime object in Java 8. Upon running the following lines: DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); LocalDateTime dt = LocalDateTime.parse("20140218", formatter); I…
retrography
  • 6,302
  • 3
  • 22
  • 32
150
votes
11 answers

How can I do time/hours arithmetic in Google Spreadsheet?

How do I do time/hour arithmetic in a Google spreadsheet? I have a value that is time (e.g., 36:00:00) and I want to divide it by another time (e.g., 3:00:00) and get 12. If I divide just one by the other, I get 288:00:00 when what I want is 12 (or…
user128807
  • 10,447
  • 17
  • 53
  • 72
146
votes
8 answers

DateTime.ToString() format that can be used in a filename or extension?

I want to add a timestamp to filenames as files are created but most of the DateTime methods I've tried output something with spaces and slashes. For instance: Debug.WriteLine(DateTime.Now.ToString()); // <-- 9/19/2012 1:41:46…
pdizz
  • 4,100
  • 4
  • 28
  • 42
139
votes
9 answers

How do I convert datetime to ISO 8601 in PHP

How do I convert my time from 2010-12-30 23:21:46 to ISO 8601 date format? (-_-;)
wow
  • 7,989
  • 17
  • 53
  • 63
125
votes
22 answers

How to convert milliseconds into human readable form?

I need to convert an arbitrary amount of milliseconds into Days, Hours, Minutes Second. For example: 10 Days, 5 hours, 13 minutes, 1 second.
FlySwat
  • 172,459
  • 74
  • 246
  • 311
117
votes
4 answers

AngularJS - convert dates in controller

Could anyone please suggest me how to convert date from this 1387843200000 format into this 24/12/2013 inside my controller? Just FYI my dates are stored in this way & when binding to edit form with input type="date" field is not being populated at…
Iladarsda
  • 10,640
  • 39
  • 106
  • 170
97
votes
6 answers

How to get current isoformat datetime string including the default timezone?

I need to produce a time string that matches the iso format yyyy-mm-ddThh:mm:ss.ssssss-ZO:NE. The now() and utcnow() class methods almost do what I want. >>> import datetime >>> #time adjusted for current timezone >>>…
deft_code
  • 57,255
  • 29
  • 141
  • 224
95
votes
9 answers

Parse DateTime string in JavaScript

Does anyone know how to parse date string in required format dd.mm.yyyy?
Azat
  • 2,275
  • 1
  • 28
  • 32
1
2 3
99 100