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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:14:43+00:00 2026-05-25T00:14:43+00:00

How to pass argument of Date to another function? My code: var myDate =

  • 0

How to pass argument of Date to another function? My code:

var myDate = new Date(data.GetOPCResult.DateTime.match(/\d+/)[0] * 1);
var datlabel = document.getElementById("ct");
datlabel.innerHTML = GetTime(myDate);

And GetTime function code:

function GetTime(DateTime) {
    var month = (DateTime.getMonth() < 10) ? "0" + (DateTime.getMonth() + 1) : (DateTime.getMonth() + 1);
    var day = (DateTime.getDate() < 10) ? "0" + DateTime.getMonth() : DateTime.getMonth();
    var hour = (DateTime.getHours() < 10) ? "0" + DateTime.getHours() : DateTime.getHours();
    var minute = (DateTime.getMinutes() < 10) ? "0" + DateTime.getMinutes() : DateTime.getMinutes();
    var second = (DateTime.getSeconds() < 10) ? "0" + DateTime.getSeconds() : DateTime.getSeconds();
    return DateTime.getDate() + "." + month + "." + DateTime.getFullYear() + " " + hour + ":" + minute + ":" + second;
}
  • 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-25T00:14:43+00:00Added an answer on May 25, 2026 at 12:14 am

    This works for me

    function GetTime(d) {
        var month = (d.getMonth() < 10) ? "0" + (d.getMonth() + 1) : (d.getMonth() + 1);
        var day = (d.getDate() < 10) ? "0" + d.getMonth() : d.getMonth();
        var hour = (d.getHours() < 10) ? "0" + d.getHours() : d.getHours();
        var minute = (d.getMinutes() < 10) ? "0" + d.getMinutes() : d.getMinutes();
        var second = (d.getSeconds() < 10) ? "0" + d.getSeconds() : d.getSeconds();
    
        return d.getDate() + "." + month + "." + d.getFullYear() + " " + hour + ":" + minute + ":" + second;
    }
    
    alert(GetTime(new Date()));
    

    Are you sure you are passing a valid Date object? Try passing new Date() instead of myDate to your GetTime. If that works, your myDate variable is not a valid Date object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass some argument to javascript function from code behind. My Javascript
I would like to pass a function as a template argument to another function
Here is my code: function testimage() { var image; image = new Image(); with
I'm trying to pass a string argument to a target function in a process.
A function takes a string as argument, example fn(string). I want to pass different
I have to pass an argument of the type Pointer to a function from
How to pass an argument to an event handler in wxPython? Here's my code:
I would like to pass an argument(s) to a method being defined using define_method,
I want to call a PHP file but want to pass an argument to
What's the best way to pass an optional argument that is nearly always 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.