date parsing [message #175387] |
Tue, 13 September 2011 20:53 |
bob
Messages: 11 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
I need to convert this Java code to php ASAP:
static String processDate(String s){
Format formatter = new SimpleDateFormat(
"E, dd MMM yyyy HH:mm:ss Z");
Date date = null;
try {
date = (Date) formatter.parseObject(s);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SimpleDateFormat sdf = new SimpleDateFormat(
"h:mm aaa - EEEEE, MMM dd, yyyy ");
String myString = sdf.format(date);
return myString;
}
Any tips?
|
|
|
Re: date parsing [message #175392 is a reply to message #175387] |
Tue, 13 September 2011 23:40 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/13/2011 4:53 PM, bob wrote:
> I need to convert this Java code to php ASAP:
>
> static String processDate(String s){
> Format formatter = new SimpleDateFormat(
> "E, dd MMM yyyy HH:mm:ss Z");
> Date date = null;
> try {
> date = (Date) formatter.parseObject(s);
> } catch (ParseException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> SimpleDateFormat sdf = new SimpleDateFormat(
> "h:mm aaa - EEEEE, MMM dd, yyyy ");
> String myString = sdf.format(date);
> return myString;
> }
>
> Any tips?
Sorry, my Java is a bit rusty.
Find out the input format, the desired output format, and create a
function to do it like you want.
Something like this I generally don't even try to match the code from
another language.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: date parsing [message #175398 is a reply to message #175392] |
Wed, 14 September 2011 07:40 |
bob
Messages: 11 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
Here's what I did
$thetime = date("g:i A - l, M j, Y ", strtotime($gamedate)) ;
On Sep 13, 6:40 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 9/13/2011 4:53 PM, bob wrote:
>
>
>
>
>
>
>
>
>
>> I need to convert this Java code to php ASAP:
>
>> static String processDate(String s){
>> Format formatter = new SimpleDateFormat(
>> "E, dd MMM yyyy HH:mm:ss Z");
>> Date date = null;
>> try {
>> date = (Date) formatter.parseObject(s);
>> } catch (ParseException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>
>> SimpleDateFormat sdf = new SimpleDateFormat(
>> "h:mm aaa - EEEEE, MMM dd, yyyy ");
>> String myString = sdf.format(date);
>> return myString;
>> }
>
>> Any tips?
>
> Sorry, my Java is a bit rusty.
>
> Find out the input format, the desired output format, and create a
> function to do it like you want.
>
> Something like this I generally don't even try to match the code from
> another language.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
|
|
|