What is an efficient way to strip the time from this returned dataset using jQuery? I need the time to exist in the database because of ordering purposes however I need to display only the date.
<adopt_date>Apr 25 2013 2:41PM</adopt_date> is an example of a result from my Web Service.
Here is how I currently usethe information if it helps:
var adopted_date = $(this).find('adopt_date').text();
Where $(this) is dataset.
Thanks!
Try this:
$("adopt_date").html(function (index, value) {
return value.replace(/\d{1,2}:\d{2}(AM|PM)/ig, '');
});
FIDDLE
You can do this with plain JavaScript:
adopted_date = adopted_date.replace(/ [0-9]*[0-9]:[0-9][0-9]A*P*M/,'');
jsFiddle example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With