Php, date manipulation? -
I am new to php and i would like to know some date manipulation things in php.
// Get current date $ date = date ("Y-M-D");
What if I want to reduce the current date and a specific date, so says "today - 2008-06-26"?
If today, a customer accepts today's date 2009-06-26, after 1 week I Want to delete my account from my database, how do I do this? (I am using mysql)
What can we do if we store the user's date in our database? For example, we can store the date of the user's fleet, so when he sent some emails to him on his late day. What else can you do?
First of all, you need, and
To understand the difference betweenis used only for the purposes of use. Never use it for mathematical additions.
returns the current timestamp
(a int
represents the current time and date).
, with no parameters, is similar to the parameters, this allows you to get the timestamp
for a set time parameter is in this order: hour, minute , Seconds, month, day, year
Now, your question :
Question 1
To manipulate time, you can do the following:
$ today = mktm (0,0,0); // today, neutral $ otherDate = mktime (0, 0, 6, 26, 2008); // 2008-06-26, Time Neutral $ sec Betterdates = $ Today- $ Other Date;
Question 2
You are better than doing something directly in your SQL. Here are the ways you can do the two most common database servers running in PHP. I'm assuming that subscribed to date
is a valid date in Datat.
--- MySQL DELETE from 'Customer' Where Now () & lt; DATE_ADD (`Date Weekly ', Interval 1 week); --- Delete PostgreSQL from "Customers" Where CURRENT_TIMESTAMP & lt; ("Date subscribed" + Interval '1 week');
Question 3
It depends on your DBMS. / html>
Comments
Post a Comment