Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlier than today.
On Fri, 13 Jan 2006 07:21:40 -0800, lwoods wrote:
[color=blue]
> I want to calculate and display the 'mm/dd/yyyy' that is 10 years earlier
> than today.
>
> How do I do that?
>
> TIA,
>
> Larry Woods[/color]
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlier than today.
Thanks, but I don't need to subtract seconds, really. I need something that
looks like this:
I need to be able to:
1. Subtract 10 years from today
2. Display that value in 'mm/dd/yyyy' format
I guess I assumed that PHP had the capability of doing this without
resorting to additional packages like PEAR
Larry
"Mladen Gogala" <gogala@sbcglob al.net> wrote in message
news:pan.2006.0 1.13.14.35.40.6 38327@sbcglobal .net...[color=blue]
> On Fri, 13 Jan 2006 07:21:40 -0800, lwoods wrote:
>[color=green]
>> I want to calculate and display the 'mm/dd/yyyy' that is 10 years earlier
>> than today.
>>
>> How do I do that?
>>
>> TIA,
>>
>> Larry Woods[/color]
>
>
> PEAR Date package can subtract/add seconds.
>
> --
> http://www.mgogala.com
>[/color]
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlierthan today.
lwoods wrote:[color=blue]
> Thanks, but I don't need to subtract seconds, really. I need something that
> looks like this:
>
> I need to be able to:
>
> 1. Subtract 10 years from today
> 2. Display that value in 'mm/dd/yyyy' format[/color]
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlier than today.
On Fri, 13 Jan 2006 07:48:34 -0800, lwoods wrote:
[color=blue]
> Thanks, but I don't need to subtract seconds, really. I need something that
> looks like this:
>
> I need to be able to:
>
> 1. Subtract 10 years from today[/color]
That only means that you have to extract enough seconds. Try with
3650*24*3600
[color=blue]
> 2. Display that value in 'mm/dd/yyyy' format[/color]
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlier than today.
"lwoods" <larry@lwoods.c om> kirjoitti
viestissä:ZGOxf .7893$JT.6131@f ed1read06...[color=blue]
>I want to calculate and display the 'mm/dd/yyyy' that is 10 years earlier
>than today.
>
> How do I do that?[/color]
$date = "12/31/2005";
echo date('d/m/Y', strtotime("$dat e -10years"));
--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.ber keley.edu/>
Kimmo Laine <antaatulla.sik anautaa@gmail.c om.NOSPAM.inval id>
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlierthan today.
lwoods wrote:[color=blue]
> I want to calculate and display the 'mm/dd/yyyy' that is 10 years earlier
> than today.
>
> How do I do that?
>
> TIA,
>
> Larry Woods[/color]
explode() it, perform the calculation, and then implode() it. That's
what I would do, anyhow.
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlierthan today.
john.d.mann@sbc global.net wrote:[color=blue]
> lwoods wrote:
>[color=green]
>> I want to calculate and display the 'mm/dd/yyyy' that is 10 years
>> earlier than today.
>>
>> How do I do that?
>>
>> TIA,
>>
>> Larry Woods[/color]
>
>
> explode() it, perform the calculation, and then implode() it. That's
> what I would do, anyhow.
>
> // configuration
> $date = '01/01/2006';
> $offset = '-10';
> $date_glue = '/';
>
> // implementation
> $temp = explode($date_g lue, $date);
> $temp[2] = $temp[2] + $offset;
> $date = implode ($date_glue, $date);
> echo $date;[/color]
That technique only works for some date calculations.
Try to take off 10 days during the first 10 days of the month or 10
months between Jan and October and you'll get strange results.
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlierthan today.
VS wrote:[color=blue]
> john.d.mann@sbc global.net wrote:
>[color=green]
>> lwoods wrote:
>>[color=darkred]
>>> I want to calculate and display the 'mm/dd/yyyy' that is 10 years
>>> earlier than today.
>>>
>>> How do I do that?
>>>
>>> TIA,
>>>
>>> Larry Woods[/color]
>>
>>
>>
>> explode() it, perform the calculation, and then implode() it. That's
>> what I would do, anyhow.
>>
>> // configuration
>> $date = '01/01/2006';
>> $offset = '-10';
>> $date_glue = '/';
>>
>> // implementation
>> $temp = explode($date_g lue, $date);
>> $temp[2] = $temp[2] + $offset;
>> $date = implode ($date_glue, $date);
>> echo $date;[/color]
>
>
> That technique only works for some date calculations.
>
> Try to take off 10 days during the first 10 days of the month or 10
> months between Jan and October and you'll get strange results.
>[/color]
Well, sure, but he was only asking about the year hehe. For the day or
month, a more advanced version would be required.
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlier than today.
On Fri, 13 Jan 2006 15:26:11 GMT, Mladen Gogala <gogala@sbcglob al.net>
wrote:
[color=blue]
>
> That only means that you have to extract enough seconds. Try with
> 3650*24*3600
>[/color]
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlierthan today.
john.d.mann@sbc global.net said the following on 13/01/2006 18:34:[color=blue]
> VS wrote:
>[color=green]
>> john.d.mann@sbc global.net wrote:
>>[color=darkred]
>>> lwoods wrote:
>>>
>>>> I want to calculate and display the 'mm/dd/yyyy' that is 10 years
>>>> earlier than today.
>>>>
>>> // configuration
>>> $date = '01/01/2006';
>>> $offset = '-10';
>>> $date_glue = '/';
>>>
>>> // implementation
>>> $temp = explode($date_g lue, $date);
>>> $temp[2] = $temp[2] + $offset;
>>> $date = implode ($date_glue, $date);
>>> echo $date;[/color]
>>
>>
>>
>> That technique only works for some date calculations.
>>
>> Try to take off 10 days during the first 10 days of the month or 10
>> months between Jan and October and you'll get strange results.
>>[/color]
>
> Well, sure, but he was only asking about the year hehe. For the day or
> month, a more advanced version would be required.
>[/color]
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlier than today.
Berimor wrote:
[color=blue]
> On Fri, 13 Jan 2006 15:26:11 GMT, Mladen Gogala <gogala@sbcglob al.net>
> wrote:
>[color=green]
>>
>> That only means that you have to extract enough seconds. Try with
>> 3650*24*3600
>>[/color]
>
> Really?
> What about leap-years?[/color]
And wasn't there a leap second at the beginning of this month?
Re: How do I do date math on 'mm/dd/yyyy'? Example: 10 years earlierthan today.
Oli Filth wrote:[color=blue]
> john.d.mann@sbc global.net said the following on 13/01/2006 18:34:
>[color=green]
>> VS wrote:
>>[color=darkred]
>>> john.d.mann@sbc global.net wrote:
>>>
>>>> lwoods wrote:
>>>>
>>>>> I want to calculate and display the 'mm/dd/yyyy' that is 10 years
>>>>> earlier than today.
>>>>>
>>>> // configuration
>>>> $date = '01/01/2006';
>>>> $offset = '-10';
>>>> $date_glue = '/';
>>>>
>>>> // implementation
>>>> $temp = explode($date_g lue, $date);
>>>> $temp[2] = $temp[2] + $offset;
>>>> $date = implode ($date_glue, $date);
>>>> echo $date;
>>>
>>>
>>>
>>>
>>> That technique only works for some date calculations.
>>>
>>> Try to take off 10 days during the first 10 days of the month or 10
>>> months between Jan and October and you'll get strange results.
>>>[/color]
>>
>> Well, sure, but he was only asking about the year hehe. For the day
>> or month, a more advanced version would be required.
>>[/color]
>
> How about 29/02/2004?
>
>[/color]
hehe - Well, the title of the thread says mm/dd/yyyy. So, again, i was
just going by the data given by the thread starter. You can always
adapt your code to handle the format of dd/mm/yyyy. Something like this...
Comment