Questions tagged [date-format]

`DateFormat` is a Java Standard Edition library class which provides utility methods to parse and format dates.

DateFormat is a Java Standard Edition library class which provides utility methods to parse and format dates.

2386 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
997
votes
41 answers

Get month name from Date

How can I generate the name of the month (e.g: Oct/October) from this date object in JavaScript? var objDate = new Date("10/11/2009");
Shyju
  • 214,206
  • 104
  • 411
  • 497
781
votes
18 answers

C# DateTime to "YYYYMMDDHHMMSS" format

I want to convert a C# DateTime to "YYYYMMDDHHMMSS" format. But I don't find a built in method to get this format? Any comments?
SARAVAN
  • 14,571
  • 16
  • 49
  • 70
610
votes
33 answers

Javascript add leading zeroes to date

I've created this script to calculate the date for 10 days in advance in the format of dd/mm/yyyy: var MyDate = new Date(); var MyDateString = new Date(); MyDate.setDate(MyDate.getDate()+10); MyDateString = MyDate.getDate() + '/' +…
Julian Coates
  • 6,129
  • 3
  • 16
  • 5
514
votes
23 answers

Change date format in a Java string

I've a String representing a date. String date_s = "2011-01-18 00:00:00.0"; I'd like to convert it to a Date and output it in YYYY-MM-DD format. 2011-01-18 How can I achieve this? Okay, based on the answers I retrieved below, here's something…
amit4444
  • 5,209
  • 3
  • 15
  • 3
408
votes
47 answers

JavaScript seconds to time string with format hh:mm:ss

I want to convert a duration of time, i.e., number of seconds to colon-separated time string (hh:mm:ss) I found some useful answers here but they all talk about converting to x hours and x minutes format. So is there a tiny snippet that does this in…
medk
  • 9,233
  • 18
  • 57
  • 79
393
votes
37 answers

Convert seconds to HH-MM-SS with JavaScript?

How can I convert seconds to an HH-MM-SS string using JavaScript?
Hannoun Yassir
  • 20,583
  • 23
  • 77
  • 112
315
votes
23 answers

Check if a string is a date value

What is an easy way to check if a value is a valid date, any known date format allowed. For example I have the values 10-11-2009, 10/11/2009, 2009-11-10T07:00:00+0000 which should all be recognized as date values, and the values 200, 10, 350, which…
Thizzer
  • 16,153
  • 28
  • 98
  • 139
239
votes
15 answers

Display current time in 12 hour format with AM/PM

Currently the time displayed as 13:35 PM However I want to display as 12 hour format with AM/PM, i.e 1:35 PM instead of 13:35 PM The current code is as below private static final int FOR_HOURS = 3600000; private static final int FOR_MIN =…
ronan
  • 4,492
  • 13
  • 47
  • 67
210
votes
10 answers

How to format Joda-Time DateTime to only mm/dd/yyyy?

I have a string "11/15/2013 08:00:00", I want to format it to "11/15/2013", what is the correct DateTimeFormatter pattern? I've tried many and googled and still unable to find the correct pattern. edit: I am looking for Joda-Time DateTimeFormatter,…
iCodeLikeImDrunk
  • 17,085
  • 35
  • 108
  • 169
206
votes
9 answers

Java SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") gives timezone as IST

I have SimpleDateFormat constructor as SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") and I am parsing string "2013-09-29T18:46:19Z". I have read that here Z represents the GMT/UTC timezone. but when I print this date on console , It prints IST…
Pradip Borde
  • 2,516
  • 4
  • 18
  • 20
161
votes
15 answers

How to format date in angularjs

I want to format date as mm/dd/yyyy. I tried the following and none of it works for me. Can anyone help me with this? reference: ui-date
user16
  • 1,649
  • 2
  • 11
  • 6
160
votes
4 answers

Rails formatting date

I am posting a date to an API and the required format is as follows: 2014-12-01T01:29:18 I can get the date from the model like so: Model.created_at.to_s That returns: 2014-12-01 01:29:18 -0500 How can I use Rails or Ruby to format it like the…
Arthur
  • 1,970
  • 4
  • 18
  • 19
159
votes
11 answers

"Java DateFormat is not threadsafe" what does this leads to?

Everybody cautions regarding Java DateFormat not being thread safe and I understand the concept theoretically. But I'm not able to visualize what actual issues we can face due to this. Say, I've a DateFormat field in a class and the same is used in…
haps10
  • 3,496
  • 6
  • 32
  • 38
1
2 3
99 100