Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:38:32+00:00 2026-06-07T12:38:32+00:00

I have a selection of time elements: [ <time class=​end datetime>​</time>​ , <time class=​end

  • 0

I have a selection of time elements:

[ <time class=​"end" datetime>​</time>​ , 
<time class=​"end" datetime=​"2011-12">​Dec 2011​</time>​ , 
<time class=​"end" datetime=​"2010-01">​Jan 2010​</time>​ , 
<time class=​"end" datetime=​"2009-01">​Jan 2009​</time>​ , 
<time class=​"end" datetime=​"2006-12">​Dec 2006​</time>​ , 
<time class=​"end" datetime=​"2006-05">​May 2006​</time>​ ]

that can be selected from the jQuery statement :

$('.workexperience .company .position > time.end')

I am trying to fill the end datetime and the InnerHTML if they are blank with the current month and date, but am having difficulty selecting the datetime attribute of the <time> tag.

  • How do I check if it the datetime attr is empty? and
  • How do I then fill the text?

I have this function to help with getting the current date and putting it in the month year (Month, YYYY) format. and can adjust it to get the number format for the datetime attribute, just dont know how to select them using JQuery.

function getCurrentDate() {
var d = new Date();
var m = new Array(7);
var y = d.getFullYear();
m[0] = "January"; m[1] = "February"; m[2] = "March"; m[3] = "April"; m[4] = "May"; m[5] = "June"; m[6] = "July"; m[7] = "August"; m[8] = "September"; m[9] = "October"; m[10] = "November"; m[11] = "December";
return m[d.getMonth()] + ", " + y; 
};`

As always, thank you for your time and help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:38:36+00:00Added an answer on June 7, 2026 at 12:38 pm

    Just use the .attr() method:

    var ends = $('.workexperience .company .position > time.end');
    ends.attr("datetime", function(i, d) {
        if (!d) // empty
            return getCurrentDate();
        return d;
    });
    

    …or, even better, the .prop() method:

    ends.prop("dateTime", function(i, d) {...});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a selection of elements that I'm trying to filter down based on
first some code: I have many elements like that: <section class=item> <div class=caption> </div>
I have a selection of elements in a jQuery object. I want to animate
I have a number of elements with the same class like this: <html> <head><title>example</title>
I have a script that adds elements to a div, rotates them for a
I have a complicated MySQL query which takes a lot of time, selecting from
I have a selection of products within my wordpress site. They are configurable products
I have a selection for some items using a spinner widget. At the moment
I have a selection of a huge set of data and I would like
I have Spatial Selection implemented on Map in my Web Application, which selects the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.