hello Habi~
This is a good question,even many Chinese also will be confused about "功夫" and "工夫"!When we mention "功夫",most foreigners would think of "Chinese kongfu".
1."工夫" and "功夫" both could mean "time",but "功夫" means "the time you have worked hard on something",for example:
(1)He was away for a short while and soon came back.
他出去才一会工夫就回来了。
(2)It took the teacher a few months to make her class under control.
老师费了几个月功夫才把她班上的学生管好。
2.About "功夫" and "工夫",generally they are interchangeable when they both mean "the time/effort/work you have spent/done on somehing":
(1)Working requires real effort.
做事须下大功夫/工夫。
(2)One cannot learn English well unless he studies hard.
除非下苦功夫/工夫,否则学不好英语。
3."功夫" means "workmanship; skill; art; ability", in this context you CAN'T replace "功夫" with "工夫"!!!!!!!
(1)If he can complete the task it depends on his skill.
他是否能完成这项任务取决于他的能力/功夫。
(2)Your abilities are not enough.
你的功夫不到家/不够。
I've thought about much time on your question,hope my answer could help you. ^^