View Full Version : Saving date in mysql db
d-machine
02-23-2013, 06:54 PM
Hi,
I have a form which includes text field.
I want to enter there a date like: 22/05/2014 (something like: date("d.m.Y",$x);)
and the information will be saved in a mysql database.
I don't know how to do it correctly since all the time the db returns be the date 31.12.1969
I'll appreciate your help!
djr33
02-23-2013, 07:35 PM
You should be using timestamps because they're a more accurate way to store dates. What's happening here is that you're actually already using timestamps somehow, and your (invalid timestap) input is being converted to the first possible date in timestamps, which is the end of 1969-- timestamps start in 1970, because dates before then are rarely relevant to computers.
What format do you want to use? If not timestamps, why not?
Are all parts of your system configured for that type of format?
d-machine
02-23-2013, 07:38 PM
I want to write a date in the future and I don't know how to convert it into timestamp
djr33
02-23-2013, 09:09 PM
Do you want to use timestamps? Is your database configured for timestamps? Is the rest of the script configured for that?
I'm still not sure exactly what the problem is.
Are you looking for a way to create a timestamp? The answer is probably the strtotime() function:
http://www.php.net/manual/en/function.strtotime.php
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.