RE: [PHP] date maniplations

From: Date: Fri, 16 Feb 2001 03:18:54 +0000
Subject: RE: [PHP] date maniplations
Groups: php.general 
Request: Send a blank email to php-general+get-40075@lists.php.net to get a copy of this message
you could use explode() function of PHP: $date = 'MM/DD/YYYY'; $date_a = explode('/', $date); $mm = $date_a[0]; $dd = $date_a[1]; $yyyy = $date_a[2]; $date = "$mm/".($dd+$n)."/$yyyy"; So here you have your date + something else ... of course your exaple is smarter since in here I could manage to have 33 days... You can however use mktime, and I believe the 1 month and 33 days will result to use as february 2, (2 month + 2 days(1 month is 31 days as january)) anyway ... explode is I believe what you are asking for. Cheers, Maxim Maletsky -----Original Message----- From: Don [mailto:don@lclcan.com] Sent: Thursday, February 15, 2001 12:48 AM To: php list Subject: [PHP] date maniplations Hello, Sorry if I am confused by the date functions in the manual but I am. Here's what I want to do: I have a string in the form MM/DD/YYYY. I wish to: 1) convert it to a date 2) add $n days to it 3) convert back to a string in the same format above I believe I can accomplish [2] and [3] with: $mytdate = date("m/d/Y",mktime(0,0,0,date("m") ,date("d")+$n,date("Y"))); How do I accomplish step 1? Can I type cast a string to a date? Thanks, Don -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#40075) next »