Date Problem in PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adilmarwat2004
Forum Commoner
Posts: 44
Joined: Fri Sep 04, 2009 11:28 pm

Date Problem in PHP?

Post by adilmarwat2004 »

I have prove the query to the mysql table as

UPDATE info SET date_retire = date_retire+ 00600000;

which set the data of retirement of emplyees.

When i display the date_retire field on php page it give the wrong result as 01-01-1970 for each record on employee.

How can i achieve the desired date from field.

please help in this regard.

Adil
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Date Problem in PHP?

Post by social_experiment »

1. What type of value are you storing in the 'date_retire' field?
2. Are you updating ALL the fields in the database at once, or one at a time?
When i display the date_retire field on php page it give the wrong result as 01-01-1970 for each record on employee.
In the query you are not specifying a record to update. If you use 'UPDATE table SET field = value' it updates ALL records in the table. To update individual records you should use

Code: Select all

<?php $q = "UPDATE table SET field = $new_value WHERE id = $specific_id";
// or something similar depending on your table structure
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply