Re: [PHP] Bilingual strtotime()
Yeah I think that's the only way out for now. I had to do something similar when using strftime() but the same can be done when using strtotime(). You just have to be careful with abbreviated names. Check out the source code here:http://code.google.com/p/raxan/source/browse/trunk/raxan/sdk/raxan/pdi/shared/raxan.datetime.php Best regards,__Raymond --- On Sun, 2/6/11, Alexis wrote: From: Alexis Subject: Re: [PHP] Bilingual strtotime() To: Cc: php-general@lists.php.net Date: Sunday, February 6, 2011, 3:38 PM On 06/02/11 04:54, Ashley Sheridan wrote: > On Sun, 2011-02-06 at 11:24 +0100, Peter Lind wrote: > >> On Feb 6, 2011 11:16 AM, "Per Jessen" wrote: >>> >>> Alexis wrote: >>> I was wondering if there was a way to use the strtotime() function when the months are in one or the other of the above two languages? >>> >>> Ah, I misread this earlier - strtotime(), not strftime(). You're >>> talking about transforming from text to a locale()-neutral format. I >>> don't think strtotime() is locale-sensitive - according to the manual: >>> >>> "The function [strtotime] expects to be given a string containing an >>> English date format" >>> >>> >>> >> >> Strtotime can read a number of formats, but does (from experience) have >> problems with some. It won't work with textual dates in anything but >> English, far as I know. >> >> Regards >> Peter > > > Is there an example of the different date formats so that we can see > what we're working with here? It sounds like it might require a little > manual intervention first (str_replace() maybe) in order for this to > work. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > So basically, the answer is no :) Looks like I'll simply do a replace of the French named months with English ones. Would have thought the length of time that PHP has been around and with people around the world, speaking more than just one language, that language support would have progressed further than it appears to have. Apparently not. But thanks for all the suggestions. Alexis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bilingual strtotime()
On 06/02/11 04:54, Ashley Sheridan wrote: On Sun, 2011-02-06 at 11:24 +0100, Peter Lind wrote: On Feb 6, 2011 11:16 AM, "Per Jessen" wrote: Alexis wrote: I was wondering if there was a way to use the strtotime() function when the months are in one or the other of the above two languages? Ah, I misread this earlier - strtotime(), not strftime(). You're talking about transforming from text to a locale()-neutral format. I don't think strtotime() is locale-sensitive - according to the manual: "The function [strtotime] expects to be given a string containing an English date format" Strtotime can read a number of formats, but does (from experience) have problems with some. It won't work with textual dates in anything but English, far as I know. Regards Peter Is there an example of the different date formats so that we can see what we're working with here? It sounds like it might require a little manual intervention first (str_replace() maybe) in order for this to work. Thanks, Ash http://www.ashleysheridan.co.uk So basically, the answer is no :) Looks like I'll simply do a replace of the French named months with English ones. Would have thought the length of time that PHP has been around and with people around the world, speaking more than just one language, that language support would have progressed further than it appears to have. Apparently not. But thanks for all the suggestions. Alexis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] latest posts help
"Michael Simiyu" wrote: >hello , am working on showing the last 3 posts showed on a message >board ( bitweaver ) and i would like to know what to add on the below >line of code to show the last 3 this is what i have that shows the >last post > >Code: >{$board.last.title|default:"Post..."|truncate:40} >a> > > >what should i add to the code above to pull the last 3 posts so i >could have it like this... (the code below just shows the latest in a >list format ) > >Code: >{if !empty($board.last)} >» {$board.last.title|default:"Post..."|truncate:40} >a> > > » title="{$board.last.title|default:"Post..."}">{$board.last.title| >default:"Post..."|truncate:40} > > » title="{$board.last.title|default:"Post..."}">{$board.last.title| >default:"Post..."|truncate:40} > > {/if} > > > >Best Regards >Michael S. This is a php list, so we can only really answer questions about php. That code looks like a smarty template (although correct me if I'm wrong) while smarty is written in php, they are not the same thing. Thanks Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] latest posts help
hello , am working on showing the last 3 posts showed on a message board ( bitweaver ) and i would like to know what to add on the below line of code to show the last 3 this is what i have that shows the last post Code: {$board.last.title|default:"Post..."|truncate:40}a> what should i add to the code above to pull the last 3 posts so i could have it like this... (the code below just shows the latest in a list format ) Code: {if !empty($board.last)} » {$board.last.title|default:"Post..."|truncate:40}a> » title="{$board.last.title|default:"Post..."}">{$board.last.title| default:"Post..."|truncate:40} » title="{$board.last.title|default:"Post..."}">{$board.last.title| default:"Post..."|truncate:40} {/if} Best Regards Michael S.
[PHP] String length output in php-generated response
Hi. I'm trying to build myself a small JSON-RPC server using PHP. Using wireshark, here's the conversation: Request: POST /.../service.php?nocache=1297004648751 HTTP/1.1 User-Agent: Opera/9.80 (X11; Linux i686; U; en) Presto/2.7.62 Version/11.01 Host: localhost Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1 Accept-Language: en-US,en;q=0.9 Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1 Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0 Referer: http://localhost/ssd/php/testrpc/build/ Connection: Keep-Alive, TE TE: deflate, gzip, chunked, identity, trailers Content-Length: 80 Content-Type: application/json Pragma: no-cache Cache-Control: no-cache X-Qooxdoo-Response-Type: application/json Content-Transfer-Encoding: binary {"service":"test.service","method":"method","id":1,"params":[{"code":"client"}]} said it, Bush junior proved it Response: HTTP/1.1 200 OK Date: Sun, 06 Feb 2011 15:04:08 GMT Server: Apache/2.2.14 (Ubuntu) Accept-Ranges: bytes X-Powered-By: PHP/5.3.2-1ubuntu4.7 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: application/json; charset=UTF-8 6f {"id":2,"result":{"service":"test.service","method":"method","id":2,"params":[{"code":"client"}]},"error":null} 0 The code to handle the request is: $request->id, "result" => $request, "error" => null ); header("Content-Type: application/json; charset=UTF-8", true); print json_encode($response); ?> The "6f" above is the length of the output in hex (I tried with various lengths of the string, it is always correct), the 0 at the end is probably some C-like string termination mark. Now, it seems the client (some JavaScript running in Firefox) has no problem decoding the answer, in spite of the hex length placed at the beginning. However, I can't rely on browsers playing nicely with incorrect JSON, so I would very much like to generate an output without the length of the response written as hex at the beginning, and without the terminating 0. What am I doing wrong? Why does the length of the string get written? I tried concatenation of an empty string at the beginning and at the end, supposing that for some reason json_encode() doesn't produce a plain string, and hoping that concatenating it to a proper string would produce a plain string, but it didn't help either. Before posting to the list, I tried searching for the problem on the web, and also experimented by outputting plain, hand-written strings. It didn't really help. Maybe it's a setup problem? My problem is, php is absolutely new to me, so I don't even know how to start diagnosing the problem (I started experimenting just a few hours ago). To decide whether it's a setup problem, here's the development platform: OS: Kubuntu 10.04.1 LTS Apache: Apache/2.2.14 (Ubuntu) PHP: 1.0.5-dev json version: 1.2.1 I don't think the browser is relevant, since it behaves the same in Opera and Firefox, and it doesn't happen in the browser, it happens on the server, since that's what wireshark shows. TIA, flj -- In politics, stupidity is not a handicap. (Napoleon) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bilingual strtotime()
On Sun, 2011-02-06 at 11:24 +0100, Peter Lind wrote: > On Feb 6, 2011 11:16 AM, "Per Jessen" wrote: > > > > Alexis wrote: > > > > > I was wondering if there was a way to use the strtotime() function > > > when the months are in one or the other of the above two languages? > > > > Ah, I misread this earlier - strtotime(), not strftime(). You're > > talking about transforming from text to a locale()-neutral format. I > > don't think strtotime() is locale-sensitive - according to the manual: > > > > "The function [strtotime] expects to be given a string containing an > > English date format" > > > > > > > > Strtotime can read a number of formats, but does (from experience) have > problems with some. It won't work with textual dates in anything but > English, far as I know. > > Regards > Peter Is there an example of the different date formats so that we can see what we're working with here? It sounds like it might require a little manual intervention first (str_replace() maybe) in order for this to work. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Bilingual strtotime()
On Feb 6, 2011 11:16 AM, "Per Jessen" wrote: > > Alexis wrote: > > > I was wondering if there was a way to use the strtotime() function > > when the months are in one or the other of the above two languages? > > Ah, I misread this earlier - strtotime(), not strftime(). You're > talking about transforming from text to a locale()-neutral format. I > don't think strtotime() is locale-sensitive - according to the manual: > > "The function [strtotime] expects to be given a string containing an > English date format" > > > Strtotime can read a number of formats, but does (from experience) have problems with some. It won't work with textual dates in anything but English, far as I know. Regards Peter
Re: [PHP] Bilingual strtotime()
Alexis wrote: > I was wondering if there was a way to use the strtotime() function > when the months are in one or the other of the above two languages? Ah, I misread this earlier - strtotime(), not strftime(). You're talking about transforming from text to a locale()-neutral format. I don't think strtotime() is locale-sensitive - according to the manual: "The function [strtotime] expects to be given a string containing an English date format" -- Per Jessen, Zürich (4.6°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Bilingual strtotime()
Alexis wrote: > On 05/02/11 13:23, Per Jessen wrote: >> Alexis wrote: >> >>> Hi, >>> >>> Living in Canada, and being a bilingual country, I have data I am >>> processing which includes dates in both English and French. >>> >>> I was wondering if there was a way to use the strtotime() function >>> when the months are in one or the other of the above two languages? >> >> Sure, strftime() is locale-sensitive. Set the locale(). >> >> >> > > Thanks > > But what if the locale is in two possible languages, all mixed > together? You have to decide then: 1) display in language#1 2) display in language#2 3) display in both. -- Per Jessen, Zürich (4.6°C) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php