1

i have a "simple" problem with the PHP timestamp (on a linux machine).

I need to get the user birthdate in year-month-date (using 3 menus - html select). When the user is born on 1970-1-1 the timestamp is zero and the application logic gets everything wrong.

How would you deal with this case?

Regards,

3
  • 2
    usually you don't take timestamp for birthdays... Commented Oct 19, 2009 at 12:00
  • If the application logic gets everything wrong, I suggest changing it. SCNR ;-) Why use a timestamp in the first place? Aren't there actual "date" data types you can use? Commented Oct 19, 2009 at 12:00
  • I agree, timestamps not a good combination with birthdates, but if you really need them why not eliminate the '0' position by adding a few seconds to the day? convert m/d/y + 60 seconds, etc. Which would never result a 0 timestamp. Commented Oct 19, 2009 at 14:15

2 Answers 2

2

As long as your dates are between the years 1901-2038 the PHP native date functions should work OK. Timestamps should not be used for birth dates. If you need to use dates outside if this range, take a look at the ADOdb Date Time Library.

Sign up to request clarification or add additional context in comments.

Comments

0

Try using built in DateTime class instead (http://php.net/manual/en/class.datetime.php)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.