Re: Using DateTimeZone

From: Date: Fri, 05 Dec 2008 07:51:38 +0000
Subject: Re: Using DateTimeZone
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-284147@lists.php.net to get a copy of this message
Lester Caine schreef: > Lester Caine wrote: >>> <?php >>> >>> setlocale(LC_TIME, "nl_NL.ISO8859-1"); >>> $d = new DateTime(); >>> echo strftime("%A, %d %B %Y", strtotime($d->format(DATE_ATOM))), >>> "\n"; >>> >>> ?> > > Does not work! it does, only there is nothing setting the timezone in that example. > Have to do > > date_default_timezone_set( $user_timezone ) ); > if ( is_numeric( $user_time )) { > $dateTimeUser = new DateTime( '@'.$user_time ); > } else { > $dateTimeUser = new DateTime( $user_time ); > } > $disptime = strtotime($dateTimeUser->format(DATE_W3C)); > echo strftime( $format, $disptime ); > > Even to get the right day! > > But as yet I have not seen ANYTHING other than English text :( > The next battle is to get it translated. you have to use setlocale() with the relevant locale for the translation your looking for before strftime() will give up something in english. don't pity you in your date battles, date's are a pita :-P >

« previous php.general (#284147) next »