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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:48:04+00:00 2026-06-13T13:48:04+00:00

I am tinkering with the Jquery Weekly Calendar Plugin (Which you can look at

  • 0

I am tinkering with the Jquery Weekly Calendar Plugin (Which you can look at the full demo here: skedyul.herokuapp.com)

Now, I’m trying to put some events dynamically using PHP but I’m fairly new to the concept of JSON.

This is my example php array to be encoded to JSON:

<?php 
        $events = array(
            array(
            "id" => 1,
            "start" => date("D M j Y H:i:s "),
            "end" =>  date("D M j Y H:i:s ",strtotime("+30 minutes")),
            "title" => "College Algebra"
            ),
            array(
            "id" => 2,
            "start" => date("D M j Y H:i:s ",strtotime("+30 minutes +1 day")),
            "end" =>  date("D M j Y H:i:s ",strtotime("+45 minutes +1 day")),
            "title" => "Calculus"
            )
        );
?>

And here is the working Javascript code with some sample data:

<script type="text/javascript">

        function getEventData() {
          var year = new Date().getFullYear();
          var month = new Date().getMonth();
          var day = new Date().getDate();
          console.log(new Date(year, month, day, 12));
          return {
             events : [
                {
                   "id":1,
                   "start": new Date(year, month, day, 12),
                   "end": new Date(year, month, day, 13, 30),
                   "title":"College Algebra",
                },
                {
                   "id":2,
                   "start": new Date(year, month, day, 14),
                   "end": new Date(year, month, day, 14, 45),
                   "title":"Statistics and Probability"
                }
             ]
          };
       }

And here, I changed the above Javascript into this (putting the json encoded php associative array)

<script type="text/javascript">

            function getEventData() {
              var year = new Date().getFullYear();
              var month = new Date().getMonth();
              var day = new Date().getDate();
              console.log(new Date(year, month, day, 12));
              return {
                 events : <?php echo json_encode($events)?>
              };
           }
</script>

It’s seems to work an doesn’t spews out errors but the problem is about the Date.
It’s not showing properly at the calendar..

How do I correctly pass JSON from PHP with dates?
Thank you 🙂

  • 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-13T13:48:05+00:00Added an answer on June 13, 2026 at 1:48 pm

    Please consider: date.js from http://code.google.com/p/datejs
    You can use Date.parse() or Date.parseExact()
    In your case, you use Date.parseExact(dateString, “d MMM d yyyy HH:mm:ss”)

    In your page, include the date.js.

    <script src="http://yoursite/path/to/date.js"></script>
    

    Then try the following…

    var dateobj = Date.parseExact(dateString, "d MMM d yyyy HH:mm:ss")
    alert(dateobj.toString());
    

    Please read http://code.google.com/p/datejs/wiki/FormatSpecifiers for date formatting

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

Sidebar

Related Questions

After tinkering around with tkinter I can't seem to make my window look quite
I have been tinkering with javasript (jquery) all day. I want to create a
I am currently tinkering with SIMBL, attempting to make my own plugin. I am
I have been tinkering with the jQuery autocomplete, and I got some parts of
I've been tinkering around with Zend-Framework and Jquery for a month or so, and
I'm tinkering with a domain name finder and want to favour those words which
I am tinkering around with jQuery and am finding it very useful and almost
[UPDATED] I'm using JQuery Validate plugin to validate a simple form. It's form HTML:
After tinkering with this for hours I am hoping someone can shed some insight
I'm currently tinkering around with Workflow Foundation. I have an activity which contains 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.