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

The Archive Base Latest Questions

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

I am trying to set up a php where that it sets the date

  • 0

I am trying to set up a php where that it sets the date up for the 1st September for each year. I am using CRON to state that everytime the date is 7th September, then the php will actually update the database for rows whose dates ae a week before that 7th September, (ist September).

Now the code below I tested for the 28th October and when I echo $selectedDate it outputs 2012-10-28 which is fine. But when I change the date to 1st September, it outputs `2011-12-01 which is obviously incorrect. it should output `2013-09-01 as the next September date will be in 2013. Then after the Ist September date has passed in 2013, then the year should change to 2014 and etc.

How can I get the correct date to be outputted?

Below is code:

$createDate = mktime(0,0,0,09,01,date("Y"));
$selectedDate =  date('Y-m-d', ($createDate));
  • 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-13T11:33:49+00:00Added an answer on June 13, 2026 at 11:33 am

    That’s because 09 is interpreted as an octal 9, which is invalid.

    It works as expected when you pass 9 instead of 09:

    $createDate = mktime(0,0,0,9,1,date("Y"));
    //                         ^ ^  No preceeding 0s.
    $selectedDate =  date('Y-m-d', ($createDate));
    
    var_dump($createDate, $selectedDate);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to coordinate cookies that were set by setcookie in PHP with
I am trying to set open_basedir in php.ini globally to /tmp/ so that I
I am trying to set up a PHP path to my Zend Framework. I
I'm trying to set up some exotic PHP code (I'm not an expert), and
I'm trying to set up a batch file to automatically deploy a php app
Trying to learn about php's arrays today. I have a set of arrays like
I'm using a IRC bot written in procedural PHP that was originally created by
I'm trying to set up MongoDB with PHP and WAMP. I had WAMP 64
I'm trying to write a simple PHP script which automatically sets up new etherpads
I have a very large data set that I'm trying to find the smallest

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.