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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:33:42+00:00 2026-06-12T21:33:42+00:00

I have current date in javascript like below: self.currentDate = ko.observable(new Date()); I want

  • 0

I have current date in javascript like below:

self.currentDate = ko.observable(new Date());

I want to format the date in yyyy-mm-dd and use inside Sammy like below:

this.get('', function () { this.app.runRoute('get', '#'+self.currentDate()) });

There are so many long process to do it. But is there any way to do it easily. Or can i use it inside document.ready function and used it here.

  • 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-12T21:33:44+00:00Added an answer on June 12, 2026 at 9:33 pm

    Take a look at datejs.

    http://www.datejs.com/

    It’s a Javascript date library, which will handle your format conversion. It extends the toString method so that you can accomplish stuff like:-

    self.currentDate().toString('yyyy-M-d')
    

    There are a couple of options for integration with Knockout, but the above will “work” in returning a yyyy-mm-dd format.

    Another approach, still using datejs, is to wrap the function in a ko.computed:-

    self.displayDate = ko.computed(function(){
       return self.currentDate().toString('yyyy-M-d');
    });
    

    If you don’t want to use datejs, you can roll your own and wrap it in a computed.

    self.displayDate = ko.computed(function(){
       var year = self.currentDate().getFullYear().toString();
       var month = (self.currentDate().getMonth() + 1).toString();
       var day   = self.currentDate().getDay().toString();
       var pad = "00";
    
       return year + '-' +
         pad.substring(0, pad.length, month.length ) + month + '-' +
         pad.substring(0, pad.length, day.length ) + day;
    
    });
    

    But seriously, look at datejs first. Why re-invent the wheel. Can’t really help you on the Sammy part, soz.

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

Sidebar

Related Questions

I have week number of current year and week day generated by date() like
In JavaScript, we can get a number representing the current date/time like so: var
In Javascript, I have this function to display the current date on our page
I have a date in this formate YYYY/MM/DD. Now I want to get the
I have a current Date object that needs to be incremented by one day
I have this function which gives me ( for a current date ) -
I have a jquery datepicker which is renders the current date by default as
I have an application that has a UILabel displaying the current date and time,
I am trying to add the current date (not time if i have the
I have an Oracle Date type to which I need to insert the current

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.