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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:19:02+00:00 2026-06-06T06:19:02+00:00

I started to learn PHP and have to find a mistake (maybe in this

  • 0

I started to learn PHP and have to find a mistake (maybe in this code):

if($newvalues["year"] != null)
   $newvalues["year"] = date("Y-m-d", strtotime($newvalues["year"]."-01-01"));

The new date has to be saved in the array “$newvalues”, but when I press the save button, it doesn’t save anything. Only if the textfield “year” is empty, the other items can be saved.

Can anyone help me, please?
Thanks.

  • 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-06T06:19:03+00:00Added an answer on June 6, 2026 at 6:19 am

    You’re basically doing:

    100 * 80 / 80
    

    Just save it as

    if($newvalues["year"] != null)
       $newvalues["year"] .= "-01-01";
    

    Or better yet, represent it as a DateTime object:

    $newvalues = array("year" => 2012);
    if ($newvalues["year"] != null) {
        $newvalues["year"] = new DateTime("{$newvalues["year"]}-01-01");
    }
    var_dump($newvalues["year"]);
    

    Using a DateTime object (And the DateTime family) gives you much better and more flexible control over your date/times.

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

Sidebar

Related Questions

I've finally started to learn PHP and I quite have trouble with it. I
I am of the PHP background and just have started to learn Django and
I have recently started to learn using of Doctrine 2.0 framework for PHP. Now
I have started to learn PHP. So installed WAMP server on my windows 7
I have just started a new job out of uni and I am learn
I've started to learn a new PHP notation I like better than the standard
I have started to learn the F3 framework (PHP) and I have gotten the
I would like to learn PHP and started reading this info's in the website:
I started to really sit down and learn PHP about a week ago, so
I've started to learn OO programming, but using the PHP language with the help

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.