I’m currently working on parsing iCal reminder strings, similar to: -P14DT0H0M0S
Using PHP, how might I be able to parse the elements of the string so that if I had:
<?
$reminder = "-P14DT0H0M0S" // somehow output to show "-2 weeks" or eve "-14 days"
// OR //
$reminder = "-P0DT3H0M0S" // somehow output to "-3 hours"
// etc...
Any help on this would be great. I’m kind of stuck on where to begin.
Many thanks!
I’m not familiar with the format, and there’s almost certainly a library available for this, but it looks like a simple regex would do the job here.
Something like: