rgb192
asked on
maybe this a factory design pattern
followup to that great answer, but adding new requirements
https://www.experts-exchange.com/questions/28236754/convert-time-in-an-object-oriented-format.html
I read about factory design pattern
there are more input types: but want the same type of output
(07/17 15:16)
(08/04 16:27)
(08/04 02:24)
(08/04 02:31)
(07/17 15:28)
(06/27 00:40)
(06/27 00:26)
(06/27 00:26)
(06/26 21:46)
1 month ago
but want these existing inputs to return time values also
(1 min ago)
(17 mins ago)
(1 hr ago)
(12 hrs ago)
1 day ago
2 days ago
1 week ago
I do not want to do an if statement outside of the class
if word contains 'ago' then go to class1
else go to class2
I am not an expert: factory design pattern may not be the best option.
https://www.experts-exchange.com/questions/28236754/convert-time-in-an-object-oriented-format.html
I read about factory design pattern
there are more input types: but want the same type of output
(07/17 15:16)
(08/04 16:27)
(08/04 02:24)
(08/04 02:31)
(07/17 15:28)
(06/27 00:40)
(06/27 00:26)
(06/27 00:26)
(06/26 21:46)
1 month ago
but want these existing inputs to return time values also
(1 min ago)
(17 mins ago)
(1 hr ago)
(12 hrs ago)
1 day ago
2 days ago
1 week ago
I do not want to do an if statement outside of the class
if word contains 'ago' then go to class1
else go to class2
I am not an expert: factory design pattern may not be the best option.
I don't think of this as being a factory; it's more of a data normalization process. I'll try to give you some examples in a moment. While I am doing that look up the "Gang of Four" and find out about their book on Design Patterns.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
time works without any changes in the code
thanks
thanks
Yeah, strtotime() and DateTime are pretty smart!