Due to the way that the DOM works, I would recommend wrapping your datetime value in a specific tag (with, perhaps, a specific class name). So instead of <nobr>08/02/1391 14:07</nobr>
, you could have <span class="datetime">8/02/1391 14:07</span>
. This would make finding your date easier, as you could use the DOM to identify tags with datetimes.
You could use jQuery's selectors to get the value....
$('.datetime').html()
...or you could use vanilla Javascript.
document.getElementsByClassName('datetime')
This is the first step in finding all of your datetimes. After that, for each datetime, you'll need to convert it into a usable format by calling the split()
function, which should split a string into an array based on a delimiter. The default delimiter is a space, so you may have to repeat this to remove the slashes. So for jQuery, you'd have...
var mydate = $('.datetime').html()
var mydateArray = mydate.split(); // This doesn't deal with nested elements, since it's an example.
...while in vanilla Javascript (javanillascript???) you'd have:
var mydate = document.getElementsByClassName('datetime')
var mydateArray = mydate.split(); // This doesn't deal with nested elements, since it's an example.
After you have split your datetime string into usable chunks, you'll need to apply the math to all of those chunks. This is the most complicated part of this solution.
However, once you've calculated your dates and reformatted them for display, you can simply set them in your HTML. In jQuery:
var myNewDate = convertHijriToStandard(date);
$('.datetime').html(myNewDate);
Note that I would recommend using jQuery for this if you're looking for maximum browser support. Your date conversion may not use jQuery, but dealing with DOM elements may be much easier if you're supporting older browsers.
Best of luck. I know this isn't a complete solution, but hopefully it should get you started. Let me know if you have any questions.