last day (14 days later) » 

6:22 AM
0
A: Internet Explorer Displays Time with Milliseconds as Nan

Newbee DevIn that case if you want to convert time to a format just use moment.js. Its good for manipulating dates in JS. They have many functions that can be useful. You can also format to any requited format and create date object in any format. Syntax moment().format('YYYY-DD-MM hh:mm:ss');

 
which means I need to first format with moment.js and then have to get the time is it so?
 
no you don't need no more that function you create because moment JS can do it alone
 
is there any thing I can do with out moment.js ?
 
@MBalajivaishnav try removing this code t = new Date(t.replace('T', ' '));
 
will that work on chrome too
 
6:22 AM
yes, I just tried it
 
Thanks a lot it worked, can you please make it as a answer so that I can accept it
 
it has bug?
I notice if you remove the t = new Date(t.replace('T', ' ')); it gives chrome a bug
 
omg then any solution
 
yey I just post a new answer
 
6:38 AM
u there
01/02/2016 10:54:09 PM (IE)

01/03/2016 10:54:09 PM (Chrome)
date differs
?..
 
what's your input
whats the date you passed?
 
2016-01-02T22:54:09.12
 
6:53 AM
wait will post my screen shot
\chrome
IE
 
strange cause it's okay in my chrome
try console.log(Tdata); to see the date
I mean to see the result of new Date
 
[date] Sat Jan 2 22:54:09 UTC+0530 2016[date] Sat Jan 2 22:54:09 UTC+0530 2016 (IE)

Sat Jan 02 2016 22:54:09 GMT+0530 (India Standard Time) (CHROME)
 
so they're the same?
 
but in HTML View its not the same
omg
do u have any idea on this
 
let me see your code
 
7:05 AM
okay
u can have a look in the question itself
 
in post question? but you only put " " + hour + ":" + min + ":" + sec + " " + format;?
" " + hour + ":" + min + ":" + sec + " " + format;
 
what code u need
I cant get u
 
your convertion
 
Thats the part of my date and Time convertion thats it
am getting the date from SQL Server Db
 
I mean you ParseTime
 
7:12 AM
yeah
function ParseTime(date) {
    var t = date.toString();
    if (isIE() == false)
    {
        t = new Date(t.replace('T', ' '));
    }
    var Tdata = new Date(t);
    console.log(Tdata);
    var format = "AM";
    var hour = Tdata.getHours();
    var min = Tdata.getMinutes();
    var sec = Tdata.getSeconds();
    if (hour > 11) { format = "PM"; }
    if (hour > 12) { hour = hour - 12; }
    if (hour == 0) { hour = 12; }
    if (min < 10) { min = "0" + min; }
    if (hour < 10) { hour = "0" + hour; }
 
how about the displaying of date in html?
because
" " + hour + ":" + min + ":" + sec + " " + format;
you have no date
 
function ParseDate(inDate) {
var d = new Date(inDate);

var month = d.getMonth() + 1;
var day = d.getDate();

var output =
(month < 10 ? '0' : '') + month + '/' +
(day < 10 ? '0' : '') + day + '/' +
d.getFullYear();
return output;
}
 
that's where the wrong part
that's what I mean
 
am parsing the date and time separately
 
yes
Why are you parsing it seperate?
 
7:19 AM
am doing bcoz I need date alone in various placec
places
 
function ParseTime(date) {
var t = date.toString();
if (isIE() == false) {
t = new Date(t.replace('T', ' '));
}
var Tdata = new Date(t);
var format = "AM";
var hour = Tdata.getHours();
var min = Tdata.getMinutes();
var sec = Tdata.getSeconds();
if (hour > 11) { format = "PM"; }
if (hour > 12) { hour = hour - 12; }
if (hour == 0) { hour = 12; }
if (min < 10) { min = "0" + min; }
if (hour < 10) { hour = "0" + hour; }
if (sec < 10) { sec = "0" + sec; }

var time = hour + ":" + min + ":" + sec + " " + format;
use that instead
 
it will affect the parse date part
 
you just stored it into json so it can seperate
 
i mean function
?..
 
remove the parse Date
that function will return both of date and time
{date: "", time:""}
you know how to use json?
 
7:26 AM
no I need the time in separate part
I cant remove it bcoz this is my requirements
omg I know how to use it
 
why it is your requirements?
what's in parseDate get the date?
you also can get the date in that function
 
see I can't able to alter with out the prior permission of my Sr Dev, hope u understand
 
ah okay
try change you parseDate to
function ParseDate(inDate) {
var d = new Date(inDate);
if (isIE() == false) {
d = new Date(t.replace('T', ' '));
}

var month = d.getMonth() + 1;
var day = d.getDate();

var output =
(month < 10 ? '0' : '') + month + '/' +
(day < 10 ? '0' : '') + day + '/' +
d.getFullYear();
return output;
}
I mean this







function ParseDate(inDate) {
if (isIE() == false) {
inDate = new Date(inDate.replace('T', ' '));
}
var d = new Date(inDate);

var month = d.getMonth() + 1;
var day = d.getDate();

var output =
(month < 10 ? '0' : '') + month + '/' +
(day < 10 ? '0' : '') + day + '/' +
d.getFullYear();
return output;
}
 
inDate.replace is not a function
 
7:42 AM
can try put this in your console
ParseDate("2016-01-02T22:54:09.12")
 
"01/03/2016" (Chrome)
"01/02/2016" (IE)
 
ah just this code first line in your ParseDate function
if (isIE() == false) {
inDate = new Date(inDate.replace('T', ' '));
}
 
yeah already placed in first line
 
still 01/03/2016?
try again
ParseDate("2016-01-02T22:54:09.12")
 
"01/02/2016" (chrome)
getting Uncaught TypeError: inDate.replace is not a function at start itself
 
7:55 AM
what did you pass in your ParseDate anyway an object?
or string?
 

last day (14 days later) »