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

  • SEARCH
  • Home
  • 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 6769123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:20+00:00 2026-05-26T15:09:20+00:00

I need this javascript function to not split a yyyy-mm-dd but split a yyymmdd.

  • 0

I need this javascript function to not split a yyyy-mm-dd but split a yyymmdd.
Current date formats are 2011-11-02 but this function needs to work with 20111102.

Script:

        function evaluateEventDate(eventdate, date){
        var eventdate = eventdate.split('-');
        var date = date.split('-');

        if (eventdate[0] === 'yyyy')
        {
            eventdate[0] = date[0];
        }

        if (eventdate[1] === 'mm') 
        {
            eventdate[1] = date[1];
        }

        if (eventdate[2] === 'dd')
        {
            eventdate[2] = date[2];
        }

        return eventdate[0]+'-'+eventdate[1]+'-'+eventdate[2];
    };
  • 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-05-26T15:09:21+00:00Added an answer on May 26, 2026 at 3:09 pm

    Continuing my work from your other question, I came up with the following function to solve your problem, using substr:

    function evaluateEventDate(eventdate, date){
        var event_y = eventdate.substr(0, 4);
        var event_m = eventdate.substr(4, 2);
        var event_d = eventdate.substr(6, 2);
    
        var date = date.split('-');
    
        if (event_y === 'yyyy')
        {
            event_y = date[0];
        }
    
        if (event_m === 'mm') 
        {
            event_m = date[1];
        }
    
        if (event_d === 'dd')
        {
            event_d = date[2];
        }
    
        return event_y + '-' + event_m + '-' + event_d;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried this JavaScript but it doesn't work - here I need to change
So from this string: name[id] I need this: id I used str.split ('[]'), but
I need to write a split function in JavaScript that splits a string into
This is a question in response to thise: Javascript AJAX function not working in
I need this for calling a C function from Java class (JNI) and I
What's the cheapest way for a JavaScript like setTimeout-function in C++? I would need
Can I call javascript function from MVC controller action (not from view page) and
I have a javascript function which get datagrid's header into THEAD tags. This code
I have a javascript function that, in most cases, needs to do something with
I need a javascript function f that given another (anonymous) function g and a

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.