Re: String to Date and Date to String Functions?

From: Date: Tue, 25 Jan 2005 07:23:26 +0000
Subject: Re: String to Date and Date to String Functions?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-207207@lists.php.net to get a copy of this message
On Tuesday 25 January 2005 03:01, Ben Edwards wrote: > Being trying to work out haw to handle dates. Basically I need a > function to convert a Date to a String and another function to convert > a string to a date. > > Exactly what format the date is held in is not relevant as long as it > is some type of standard (i.e. Unix Timestamps). > > Both the functions will require a format string (such ad DD/MM/YYY) > and again the format/syntax of this is irrelevant, as long as they are > the same for both . > > String to Date Function > ---------------------------- > return date stringToDate( str Date, str Format ) > e.g. $todayDt = stringToDate( '01/01/2003','DD/MM/YYYY' ); > > Date to String Function > ---------------------------- > return str dateToString( date Date, str Format ) > e.g. $todayStr = dateToString ( $todayDt,'DD/MM/YYYY' ); > > Anyone know of any functions that do this or have pointers as to how > it can be done. > > Ben Have you looked at date() and strtotime() ? -- David Robley How do you make Windows faster ? Throw it harder

« previous php.general (#207207) next »