[PHP] Re: date formatting

2007-08-30 Thread Haydar TUNA
Hello,
 You can DATE_FORMAT MySQL Command in your SQL Query. For example:
select DATE_FORMAT(yourdatetimefield,'%Y-%m-%d') from yourtable

-- 
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net

Mike Ryan [EMAIL PROTECTED], haber iletisinde þunlarý 
yazdý:[EMAIL PROTECTED]
I would like to have my users input the date formate as mm-dd- mysql
 wants the data to come down as -mm-dd.

 The question I have is how do I convert from the mm-dd- to -mm-dd 
 so
 that I can write it out to the database? 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Date Formatting/Reading

2001-12-13 Thread Jeremy Reed

Got a question, I just noticed your signature, 'earn up to $10 per order
selling our PHP Scripts'.  Are you paying us to help you out?  =)  Just
messing with ya.

Anyway, you'd probably want to use a 'DATE' field.

For checking the passing of a month, the easiest way would be to use the
getdate() function.  You can check the numerical value of the month and day
to see if a month has passed.  The only thing you might want to be careful
is if someone signs up on the 29-31, because February only has 28 days so
the days (29-31) would never match up.  And of course the same goes for
months with 30 days and people who sign up on the 31st.

Unfortunately, I do not know of a way to do 'math' with dates to get the 30
day difference.  I'm sure that with a little effort, you could write
something that will do it.

EXAMPLE---
$today = getdate();
$month = $today['month'];
$mday = $today['mday'];

///get date from database
if ((($month - $dbmonth) == 1)  ($mday == $dbday)) {
///time to renew
///also take into account the transition from December to January, so
$month-$dbmonth == -12
}
-END-

Best regards,

Jeremy Reed

Phpgalaxy.Com [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi! =)

 I'm doing a website that will be using a pay-per-month membership
 program. There's a field for 'lastpaid' that holds the date the last
 paid (sorry to state the obvious). My questions are these:
 1) What would be the best way to format it so PHP can see if it's been
 30 days since it was last paid?
 2) What line of code would be used to check?
 3) Would I set the field type to DATE, DATETIME, TIMESTAMP or soemthing
 else?

 Any help you can give would be much appreciated! I woulda taken the time
 to study it more in-depth but I'm trying to get as much done on this in
 5 hours as I can. =)

  ~ Tim

 --
 From PHPGalaxy.com, earn up to $10 per order selling our PHP Scripts
 and Software on your Site. http://www.phpgalaxy.com/aff/

 Also, get a fast free POP3 email account, you @php.la at
 http://www.phpgalaxy.com/search/





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]