Changing T in date to normal date [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
How to format a JavaScript date
47 answers
I am using JSX to show data in my front end
<p className="projectBoxes-other-para">{data["end.time"]} </p>
I am getting the date from API call. The above displays something like this
2016-10-30T11:25:38-04:00
Now, the T doesn't make sense to me and something I don't want show my users as well
So how can I convert it into my GMT time? in JSX? Also, if someone can explain me what does T mean here?
javascript
marked as duplicate by Jonas Wilms
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
How to format a JavaScript date
47 answers
I am using JSX to show data in my front end
<p className="projectBoxes-other-para">{data["end.time"]} </p>
I am getting the date from API call. The above displays something like this
2016-10-30T11:25:38-04:00
Now, the T doesn't make sense to me and something I don't want show my users as well
So how can I convert it into my GMT time? in JSX? Also, if someone can explain me what does T mean here?
javascript
marked as duplicate by Jonas Wilms
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
TheT
seperates day and time, and you have to parse it as a Date and then format it. MomentJS is a popular library for that.
– Jonas Wilms
Nov 11 at 16:59
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How to format a JavaScript date
47 answers
I am using JSX to show data in my front end
<p className="projectBoxes-other-para">{data["end.time"]} </p>
I am getting the date from API call. The above displays something like this
2016-10-30T11:25:38-04:00
Now, the T doesn't make sense to me and something I don't want show my users as well
So how can I convert it into my GMT time? in JSX? Also, if someone can explain me what does T mean here?
javascript
This question already has an answer here:
How to format a JavaScript date
47 answers
I am using JSX to show data in my front end
<p className="projectBoxes-other-para">{data["end.time"]} </p>
I am getting the date from API call. The above displays something like this
2016-10-30T11:25:38-04:00
Now, the T doesn't make sense to me and something I don't want show my users as well
So how can I convert it into my GMT time? in JSX? Also, if someone can explain me what does T mean here?
This question already has an answer here:
How to format a JavaScript date
47 answers
javascript
javascript
asked Nov 11 at 16:42
KuchBhi
754320
754320
marked as duplicate by Jonas Wilms
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Jonas Wilms
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
TheT
seperates day and time, and you have to parse it as a Date and then format it. MomentJS is a popular library for that.
– Jonas Wilms
Nov 11 at 16:59
add a comment |
TheT
seperates day and time, and you have to parse it as a Date and then format it. MomentJS is a popular library for that.
– Jonas Wilms
Nov 11 at 16:59
The
T
seperates day and time, and you have to parse it as a Date and then format it. MomentJS is a popular library for that.– Jonas Wilms
Nov 11 at 16:59
The
T
seperates day and time, and you have to parse it as a Date and then format it. MomentJS is a popular library for that.– Jonas Wilms
Nov 11 at 16:59
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Short answer:
<p className="projectBoxes-other-para">
{new Date(data['end.time']).toLocaleDateString()}
</p>
'T' is what separates the date from the time in ISO representation. It's what you get from javascript's Date().toISOString()
.
Since your input is a string and not a Date() class, you need to convert it first by creating a Date object from it:
let date = new Date(data["end.time"])
There are lots of methods of formatting dates. You haven't said what you want, so hard to make a recommendation, but for example, to avoid the 'T', you can use extract the date and time independently:
let now = new Date('2016-10-30T11:25:38-04:00');
let dateString = now.toLocaleDateString();
let timeString = now.toLocaleTimeString();
console.log(dateString + ', ' + timeString);
.toLocaleDateString is not a function
– KuchBhi
Nov 11 at 17:03
It's a method of the javascript Date() class. See w3schools.com/jsref/jsref_tolocaledatestring.asp
– Jim B.
Nov 11 at 17:04
I am doing something like thisdata["end.time"].toLocaleDateString()}
If i do something like thisdata["end.time]
it logs this 2016-11-15T06:00:00-05:00
– KuchBhi
Nov 11 at 17:06
Ah, your data["end.time"] is a string. I'll update the answer...
– Jim B.
Nov 11 at 17:07
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Short answer:
<p className="projectBoxes-other-para">
{new Date(data['end.time']).toLocaleDateString()}
</p>
'T' is what separates the date from the time in ISO representation. It's what you get from javascript's Date().toISOString()
.
Since your input is a string and not a Date() class, you need to convert it first by creating a Date object from it:
let date = new Date(data["end.time"])
There are lots of methods of formatting dates. You haven't said what you want, so hard to make a recommendation, but for example, to avoid the 'T', you can use extract the date and time independently:
let now = new Date('2016-10-30T11:25:38-04:00');
let dateString = now.toLocaleDateString();
let timeString = now.toLocaleTimeString();
console.log(dateString + ', ' + timeString);
.toLocaleDateString is not a function
– KuchBhi
Nov 11 at 17:03
It's a method of the javascript Date() class. See w3schools.com/jsref/jsref_tolocaledatestring.asp
– Jim B.
Nov 11 at 17:04
I am doing something like thisdata["end.time"].toLocaleDateString()}
If i do something like thisdata["end.time]
it logs this 2016-11-15T06:00:00-05:00
– KuchBhi
Nov 11 at 17:06
Ah, your data["end.time"] is a string. I'll update the answer...
– Jim B.
Nov 11 at 17:07
add a comment |
up vote
0
down vote
accepted
Short answer:
<p className="projectBoxes-other-para">
{new Date(data['end.time']).toLocaleDateString()}
</p>
'T' is what separates the date from the time in ISO representation. It's what you get from javascript's Date().toISOString()
.
Since your input is a string and not a Date() class, you need to convert it first by creating a Date object from it:
let date = new Date(data["end.time"])
There are lots of methods of formatting dates. You haven't said what you want, so hard to make a recommendation, but for example, to avoid the 'T', you can use extract the date and time independently:
let now = new Date('2016-10-30T11:25:38-04:00');
let dateString = now.toLocaleDateString();
let timeString = now.toLocaleTimeString();
console.log(dateString + ', ' + timeString);
.toLocaleDateString is not a function
– KuchBhi
Nov 11 at 17:03
It's a method of the javascript Date() class. See w3schools.com/jsref/jsref_tolocaledatestring.asp
– Jim B.
Nov 11 at 17:04
I am doing something like thisdata["end.time"].toLocaleDateString()}
If i do something like thisdata["end.time]
it logs this 2016-11-15T06:00:00-05:00
– KuchBhi
Nov 11 at 17:06
Ah, your data["end.time"] is a string. I'll update the answer...
– Jim B.
Nov 11 at 17:07
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Short answer:
<p className="projectBoxes-other-para">
{new Date(data['end.time']).toLocaleDateString()}
</p>
'T' is what separates the date from the time in ISO representation. It's what you get from javascript's Date().toISOString()
.
Since your input is a string and not a Date() class, you need to convert it first by creating a Date object from it:
let date = new Date(data["end.time"])
There are lots of methods of formatting dates. You haven't said what you want, so hard to make a recommendation, but for example, to avoid the 'T', you can use extract the date and time independently:
let now = new Date('2016-10-30T11:25:38-04:00');
let dateString = now.toLocaleDateString();
let timeString = now.toLocaleTimeString();
console.log(dateString + ', ' + timeString);
Short answer:
<p className="projectBoxes-other-para">
{new Date(data['end.time']).toLocaleDateString()}
</p>
'T' is what separates the date from the time in ISO representation. It's what you get from javascript's Date().toISOString()
.
Since your input is a string and not a Date() class, you need to convert it first by creating a Date object from it:
let date = new Date(data["end.time"])
There are lots of methods of formatting dates. You haven't said what you want, so hard to make a recommendation, but for example, to avoid the 'T', you can use extract the date and time independently:
let now = new Date('2016-10-30T11:25:38-04:00');
let dateString = now.toLocaleDateString();
let timeString = now.toLocaleTimeString();
console.log(dateString + ', ' + timeString);
let now = new Date('2016-10-30T11:25:38-04:00');
let dateString = now.toLocaleDateString();
let timeString = now.toLocaleTimeString();
console.log(dateString + ', ' + timeString);
let now = new Date('2016-10-30T11:25:38-04:00');
let dateString = now.toLocaleDateString();
let timeString = now.toLocaleTimeString();
console.log(dateString + ', ' + timeString);
edited Nov 11 at 17:14
answered Nov 11 at 16:59
Jim B.
2,6261928
2,6261928
.toLocaleDateString is not a function
– KuchBhi
Nov 11 at 17:03
It's a method of the javascript Date() class. See w3schools.com/jsref/jsref_tolocaledatestring.asp
– Jim B.
Nov 11 at 17:04
I am doing something like thisdata["end.time"].toLocaleDateString()}
If i do something like thisdata["end.time]
it logs this 2016-11-15T06:00:00-05:00
– KuchBhi
Nov 11 at 17:06
Ah, your data["end.time"] is a string. I'll update the answer...
– Jim B.
Nov 11 at 17:07
add a comment |
.toLocaleDateString is not a function
– KuchBhi
Nov 11 at 17:03
It's a method of the javascript Date() class. See w3schools.com/jsref/jsref_tolocaledatestring.asp
– Jim B.
Nov 11 at 17:04
I am doing something like thisdata["end.time"].toLocaleDateString()}
If i do something like thisdata["end.time]
it logs this 2016-11-15T06:00:00-05:00
– KuchBhi
Nov 11 at 17:06
Ah, your data["end.time"] is a string. I'll update the answer...
– Jim B.
Nov 11 at 17:07
.toLocaleDateString is not a function
– KuchBhi
Nov 11 at 17:03
.toLocaleDateString is not a function
– KuchBhi
Nov 11 at 17:03
It's a method of the javascript Date() class. See w3schools.com/jsref/jsref_tolocaledatestring.asp
– Jim B.
Nov 11 at 17:04
It's a method of the javascript Date() class. See w3schools.com/jsref/jsref_tolocaledatestring.asp
– Jim B.
Nov 11 at 17:04
I am doing something like this
data["end.time"].toLocaleDateString()}
If i do something like this data["end.time]
it logs this 2016-11-15T06:00:00-05:00– KuchBhi
Nov 11 at 17:06
I am doing something like this
data["end.time"].toLocaleDateString()}
If i do something like this data["end.time]
it logs this 2016-11-15T06:00:00-05:00– KuchBhi
Nov 11 at 17:06
Ah, your data["end.time"] is a string. I'll update the answer...
– Jim B.
Nov 11 at 17:07
Ah, your data["end.time"] is a string. I'll update the answer...
– Jim B.
Nov 11 at 17:07
add a comment |
The
T
seperates day and time, and you have to parse it as a Date and then format it. MomentJS is a popular library for that.– Jonas Wilms
Nov 11 at 16:59