0

I am using date function in javascript to get the currentDate. as

var currentTime =new Date()

But it is giving me different response in IE and Firefox as

Consider for today's Date

IE - Tue 24 Apr 17:05:22 UTC 0530 2012

Mozilla - Tue 24 Apr 17:05:22 2012 GMT 0530

The Problem is that I Want to convert today's date which is in "String" to "Date" into format - EEE mmm-dd hh:mm:ss IST yyyy

But as i m getting different response in this browser I m not getting how to apply simpleDateformatter to convert current date and time to the suitable format .

iRunner
  • 1,472
  • 6
  • 25
  • 40
  • have a look @ [formatting-a-date-in-javascript](http://stackoverflow.com/questions/1056728/formatting-a-date-in-javascript) – Sridhar G Apr 24 '12 at 12:13
  • Is SimpleDateFormat a JavaScript library you've found somewhere? A link might help. All I can find is references to the Java class. – alnorth29 Apr 24 '12 at 12:13

1 Answers1

2

You can use functions of object Date. For example:

var currentTime = new Date();
var date = currentTime.getDate();
var day = currentTime.getDay();
var hours = currentTime.getHours();

With help this functions you can convert current date and time to the suitable format.

S-e-r-g-y
  • 101
  • 1
  • 2
  • 7
  • Ya ,I done it in the same way n convert it into suitable format.Thank u so much for this answer. really helped me – iRunner Apr 25 '12 at 13:03