Re: [PHP] newbie date time question

2011-06-22 Thread David Nicholls
On 23/06/11 1:02 AM, Stuart Dallas wrote: On Wednesday, 22 June 2011 at 15:59, David Nicholls wrote: OK, looks like I have fixed problem, using: $format = 'd/m/Y g:i:s A'; $dt = date_create_from_format($format, $d[0]); $dt2 = date('r', $dt->getTimestamp()); $data[] = array(strtotime($

Re: [PHP] newbie date time question

2011-06-22 Thread Stuart Dallas
On Wednesday, 22 June 2011 at 15:59, David Nicholls wrote: > OK, looks like I have fixed problem, using: > > $format = 'd/m/Y g:i:s A'; > $dt = date_create_from_format($format, $d[0]); > $dt2 = date('r', $dt->getTimestamp()); > $data[] = array(strtotime($dt2), $d[1]); > > Not elegant but it

Re: [PHP] newbie date time question

2011-06-22 Thread David Nicholls
OK, looks like I have fixed problem, using: $format = 'd/m/Y g:i:s A'; $dt = date_create_from_format($format, $d[0]); $dt2 = date('r', $dt->getTimestamp()); $data[] = array(strtotime($dt2), $d[1]); Not elegant but it gives me the date/time value. Thanks, Adam and

Re: [PHP] newbie date time question

2011-06-22 Thread Richard Quadling
On 22 June 2011 15:05, David Nicholls wrote: > I'm trying to convert a date and time string using strtotime() > > The date and time strings are the first entry in each line in a csv file in > the form: > > 22/06/2011 9:47:20 PM, data1, data2,... > > I've been trying to use the following approach,

Re: [PHP] newbie date time question

2011-06-22 Thread Adam Balogh
$dt is an object as the error says, so you cant echo it, becouse its not a string (it can be with __toString magic method, or use print_r/var_dump to output your object). Try the format ( http://www.php.net/manual/en/datetime.format.php) method on your $dt object. On Wed, Jun 22, 2011 at 4:41 PM,

Re: [PHP] newbie date time question

2011-06-22 Thread David Nicholls
On 23/06/11 12:30 AM, Richard Quadling wrote: On 22 June 2011 15:05, David Nicholls wrote: I'm trying to convert a date and time string using strtotime() The date and time strings are the first entry in each line in a csv file in the form: 22/06/2011 9:47:20 PM, data1, data2,... I've been tr

Re: [PHP] newbie date time question

2011-06-22 Thread David Nicholls
On 23/06/11 12:23 AM, Adam Balogh wrote: hi, you have a PM(/AM) in your date ($d[0]), so put an "A" (Uppercase Ante meridiem and Post meridiem) format char to your $format variable. b3ha Thanks, Adam. Tried that and it's now throwing an error: Catchable fatal error: Object of class DateTime