
05-19-06, 07:24 AM
|
 |
Wannabe Coder
|
|
Join Date: Mar 2006
Posts: 216
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
|
splitting up the date
hello everyone, i wud appreciate it if someone tellme how to split a date. the date is in the format of yyyy-mm-dd(eg, 2006-04-01). can i store the year , month , date in different variables ? i want to split this date to year, month and date and store it in different variables., like $year = 2006, $month=04 and date=01. is that possible ?
thanks a lot in advance..
|

05-19-06, 07:38 AM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
|
|

05-19-06, 07:39 AM
|
 |
Code Guru
|
|
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by n3wb!e
hello everyone, i wud appreciate it if someone tellme how to split a date. the date is in the format of yyyy-mm-dd(eg, 2006-04-01). can i store the year , month , date in different variables ? i want to split this date to year, month and date and store it in different variables., like $year = 2006, $month=04 and date=01. is that possible ?
thanks a lot in advance..
|
EDIT: LOL, beat me by like 30 seconds, but his is better, with the list() command
Last edited by Christian; 05-19-06 at 12:58 PM.
Reason: Merged :)
|

05-19-06, 07:48 AM
|
 |
Wannabe Coder
|
|
Join Date: Mar 2006
Posts: 216
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
thanks a lotttttttttttttt.. wow! this was quick ! thanks again amigos.. have a great day. 
|

05-19-06, 07:59 AM
|
 |
Wannabe Coder
|
|
Join Date: Mar 2006
Posts: 216
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
oops.. i wud like to ask you guys one more question. the scenario is : a user has applied for a job on 2006-03-19..(yyyy-mm-dd).. i have a hyperlink on the page which when clicked, should subtract the applied date(2006-02-01) from current date(eg,2006-05-19) and should show the user when he applied for the job.. (in days, as in , 62 days).. is it possible ?
yup, thanks in advance 
|

05-19-06, 08:03 AM
|
 |
Wannabe Coder
|
|
Join Date: Mar 2006
Posts: 216
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
i mean, i hv no clue how to subtract 2 dates and find out the difference between their dates. <?
$dateDiff = mktime(0,0,0,04,20,2006) - mktime(0,0,0,04,10,2006);
echo '<br />Months Difference = '. floor($dateDiff/60/60/24/7/4);
echo '<br />Days Difference = '. floor($dateDiff/60/60/24);
?>
is working but not as i have stated above.. plz help !
|

05-19-06, 08:13 AM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
You could use the strtotime() function and the function that posted Keith in your other thread
http://www.programmingtalk.com/showthread.php?t=28935
This converts the dates to timestamp.
And this calculates the difference.
|
|
The Following User Says Thank You to Nico For This Useful Post:
|
|

05-19-06, 10:24 AM
|
 |
Community Liaison
|
|
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
|
|
|
Last edited by Keith; 05-19-06 at 10:27 AM.
|

05-19-06, 05:25 PM
|
 |
Community Liaison
|
|
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
|
|
Oops! Totally missed the link you gave... jeez.
|

05-19-06, 06:43 PM
|
 |
Newbie Coder
|
|
Join Date: May 2006
Location: Saint Louis, Missouri
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by nico_swd
|
And that would be the best method in my opinion.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|