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 6391991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:45:18+00:00 2026-05-25T03:45:18+00:00

I’m trying to create a new record where one of the fields is a

  • 0

I’m trying to create a new record where one of the fields is a DataTime field.

I always get the “The date-time format for Thu Sep 01 19:25:20 2011 is invalid, or value is outside the supported range.” error.

I’ve tried multiple format options. With Date.parse, Date.parseExact, … Here ‘s my last attempt:

//date input format = 2011-02-15 11:05:22

    var year = register_date.substring(0, 4);
    var month = register_date.substring(5, 7);
    var day = register_date.substring(8, 10);
    var hours = register_date.substring(11, 13);
    var minutes = register_date.substring(14, 16);
    var seconds = register_date.substring(17, 19);


    var datetime = Date(Date.UTC(year, month, day, hours, minutes,seconds)); 

    //var datetime = Date.parseExact(register_date, "yyyy-mm-dd HH:mm:ss");

    regFields[4] = new CRMField("ave_subscriptiondate", datetime);
  • 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-25T03:45:18+00:00Added an answer on May 25, 2026 at 3:45 am

    Include the code below and you can just do:

    datetime.toCRMFormat();
    

    This code was found in this useful CRM 2011 JS library

    // Formats the date to CRM format
    Date.prototype.toCRMFormat = function()
    {
        var d = this;
        var f = d.Format("yyyy-mm-ddThh:MM:ss+" + (-d.getTimezoneOffset()/60) + ":00");
    
        return f;
    }
    
    // Formats the date into a certain format
    Date.prototype.Format = function(format)
    {
       var d = this;
       var f = "";
    
    try {
        f = f + format.replace( /dd|mm|yyyy|MM|hh|ss|ms|APM|\s|\/|\-|,|\./ig , 
        function match()
        {
        switch(arguments[0])
        {
         case "dd": 
            var dd = d.getDate();
            return (dd < 10)? "0" + dd : dd;
         case "mm":
            var mm = d.getMonth() + 1;
            return (mm < 10)? "0" + mm : mm; 
         case "yyyy": return d.getFullYear();
         case "hh": 
            var hh = d.getHours();
            return (hh < 10)? "0" + hh : hh;
         case "MM": 
            var MM = d.getMinutes(); 
            return (MM < 10)? "0" + MM : MM;
         case "ss": 
            var ss = d.getSeconds(); 
            return (ss < 10)? "0" + ss : ss;
         case "ms": return d.getMilliseconds();
         case "APM": 
            var apm = d.getHours(); 
            return (apm < 12)? "AM" : "PM";
         default: return arguments[0];
        }
        });
    }
    catch(err)
    {
    }
    
       return f;
    }
    

    Or if you want them as regular functions instead of extensions on Date such as dateToCRMFormat(datetime)

    // Formats the date to CRM format
    function dateToCRMFormat (date)
    {
        return dateFormat(date, "yyyy-mm-ddThh:MM:ss+" + (-date.getTimezoneOffset()/60) + ":00");
    }
    
    
    // Formats the date into a certain format
    function dateFormat (date, format)
    {
       var f = "";
    
    try {
        f = f + format.replace( /dd|mm|yyyy|MM|hh|ss|ms|APM|\s|\/|\-|,|\./ig , 
        function match()
        {
        switch(arguments[0])
        {
         case "dd": 
            var dd = date.getDate();
            return (dd < 10)? "0" + dd : dd;
         case "mm":
            var mm = date.getMonth() + 1;
            return (mm < 10)? "0" + mm : mm; 
         case "yyyy": return date.getFullYear();
         case "hh": 
            var hh = date.getHours();
            return (hh < 10)? "0" + hh : hh;
         case "MM": 
            var MM = date.getMinutes(); 
            return (MM < 10)? "0" + MM : MM;
         case "ss": 
            var ss = date.getSeconds(); 
            return (ss < 10)? "0" + ss : ss;
         case "ms": return date.getMilliseconds();
         case "APM": 
            var apm = date.getHours(); 
            return (apm < 12)? "AM" : "PM";
         default: return arguments[0];
        }
        });
    }
    catch(err)
    {
    }
    
       return f;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.