[NTLUG:Discuss] verify that a text string is a valid date.

Fred James fredjame at fredjame.cnc.net
Thu Feb 2 13:53:50 CST 2006


Chris Cox wrote:

>Fred James wrote:
>  
>
>>Chris Cox wrote:
>>
>>    
>>
>>>$ mydate="2006-02-01"
>>>$ date -d "$mydate"
>>>Feb 28 00:00:00 CST 2006
>>>$ echo $?
>>>0
>>>$ mybaddate="2006-02-29"
>>>$ date -d "$mybaddate"
>>>date: invalid date `2006-02-29'
>>>$ echo $?
>>>1
>>> 
>>>
>>>      
>>>
>>Chris Cox
>>My Mileage Did Vary - see below - as I was unable to duplicate the
>>results on any of the 5 different types of machines/OSs I have available
>>to me.  Did I do it wrong?
>>    
>>
>
>No... I don't think so... but you need to get the latest GNU date
>if you haven't already.
>
>What does date --version show?
>
>I tested using GNU core utils 5.3.0
>(that which comes with SUSE 9.3)
>
>  
>
Chris Cox
Ah!  The clouds part - thank you for the clarification.  (date 
(coreutils) 4.5.7).
Regards
Fred James




More information about the Discuss mailing list