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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:08:41+00:00 2026-06-12T18:08:41+00:00

I am using a jquery date picker and also setting a date through php

  • 0

I am using a jquery date picker and also setting a date through php date(‘Y-m-D’) functions. Both of them give different date for today. Jquery picker fills the field with the date that is one day ahead of php date(). Here is the function for jquery. I need jquery to show same date for today as php.

<script type="text/javascript" charset="utf-8">
        var $j = jQuery.noConflict();                   
         $j(function()
            {

                // initialise the "Select date" link
                $j('#date-pick')
                    .datePicker(
                        // associate the link with a date picker
                        {
                            createButton:false,
                            startDate: '01/01/1970',
                            endDate: (new Date()).asString()
                            //endDate:<?php echo date('y-m-d'); ?>
                        }
                    ).bind(
                        // when the link is clicked display the date picker
                        'click',
                        function()
                        {
                            updateSelects($j(this).dpGetSelected()[0]);
                            $j(this).dpDisplay();
                            return false;
                        }
                    ).bind(
                        // when a date is selected update the SELECTs
                        'dateSelected',
                        function(e, selectedDate, $td, state)
                        {
                            updateSelects(selectedDate);
                        }
                    ).bind(
                        'dpClosed',
                        function(e, selected)
                        {
                            updateSelects(selected[0]);
                        }
                    ).val(new Date().asString()).trigger('change');

                var updateSelects = function (selectedDate)
                {
                    var selectedDate = new Date(selectedDate);
                    if(selectedDate != "Invalid Date")
                    {
                    $j('#d').val(selectedDate.getDate());
                    $j('#m').val(selectedDate.getMonth()+1);
                    $j('#y').val(selectedDate.getFullYear());
                    }
                }
                // listen for when the selects are changed and update the picker

                // default the position of the selects to today
                var today = new Date();
                updateSelects(today.getTime());

            });
        </script>
  • 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-12T18:08:42+00:00Added an answer on June 12, 2026 at 6:08 pm

    jQuery uses the client computer’s date while php uses the server’s date. They’re basically different if you haven’t set the default timezone in php. Take a look at this:
    http://php.net/manual/en/function.date-default-timezone-set.php

    You can set the default timezone in php.ini file located on the PHP main directory (Eg. PHP5.4)

    As for the using of the server’s date in the datepicker:

    A quick google search lead me to this: how to display server side dates in jquery datepicker?
    basically what they have done is creating a new date based on the current timestamp:

    $timestamp = strtotime("2012-08-02");
    
    minDate: new Date('<?php echo $timestamp; ?>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a ready made jquery date picker with ASP.NET text boxes. I'm also
I am using jquery date picker in textbox and i want the user cannot
I am using the jQuery Date picker, but it is too heavy, the minified
I'm using the jQuery date picker widget and it works nicely but I'm confused
How to disable a list of holidays using jquery date picker?
I have a date field on a PHP website and I'm using jQuery Mobile
I'm using the jQuery UI Date Picker on mobile web and testing in Android
Im using Jquery datepicker and also a PhP calender in my webpage. I want
I'm using the jQuery Date Picker plugin by Kelvin Luck ( http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/ ) and
Ok I'm using the jQuery Mobile Framework and adding the Experimental Date Picker but

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.