time/date function into time/date type field in mysql

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
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

time/date function into time/date type field in mysql

Post by mickd »

hi, i was wondering if anyone could clear up a small problem i have.

could anyone enlighten me on how to insert a date/time into a date/time field? do you have to use the php date/time function?

also,

once a date/time is entered into the field, how would you go about editing it say for example increase the date by 1 day every day? (not reset it to the current date)

thanks, any help appriciated.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

What is the current date formate for date/time you have?

If it's like Jan 05, 2005 at 12:58 PM -- then it'd be varchar
If it's a unix timestamp -- then int

etc...

Also, to get your date to change every day you'd have to have a script ran every day that would do that, or run a cron job
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

If i need to change a lot of timestamps everyday it's probably a bad solution.. In that case i would suggest calculating the actual timestap based on the difference between now() and the original timestamp.


Anyway, a little search on this forum will return a load of useful posts that mention the options to handle date and time between php and mysql. Probably ADOdb has the most powerful feature because you can it accros different DBMS.
Post Reply