$(".dateTime").text(Date);
gives the output:
Thu Jan 23 2014 14:25:02 GMT+0530 (India Standard Time)
what i want:
Thu Jan 23 2014
Is there any function for Date Only not time?
$(".dateTime").text(Date);
gives the output:
Thu Jan 23 2014 14:25:02 GMT+0530 (India Standard Time)
what i want:
Thu Jan 23 2014
Is there any function for Date Only not time?
Use toDateString() extension method;
dateTimeEmelemt.toDateString()
The above will give Thu Jan 23 2014
you can use jquery ui date picker. it will give you all the functionality you need.
here is an axample
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Format date</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
$( "#format" ).change(function() {
$( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );
});
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker" size="30"></p>
<p>Format options:<br>
<select id="format">
<option value="mm/dd/yy">Default - mm/dd/yy</option>
<option value="yy-mm-dd">ISO 8601 - yy-mm-dd</option>
<option value="d M, y">Short - d M, y</option>
<option value="d MM, y">Medium - d MM, y</option>
<option value="DD, d MM, yy">Full - DD, d MM, yy</option>
<option value="'day' d 'of' MM 'in the year' yy">With text - 'day' d 'of' MM 'in the year' yy</option>
</select>
</p>
</body>
</html>
This is how you can do it without Date.toDateString()
(just for fun :P)
var dateTimeEmelemt = $(".dateTime").text(Date);
dateTimeEmelemt = dateTimeEmelemt.split(':')[0];
var shortDateTime = dateTimeEmelemt.substr(0, dateTimeEmelemt.length - 3);
console.log(shortDateTime);