php-general Digest 26 Jul 2013 09:18:07 -0000 Issue 8310

2013-07-26 Thread php-general-digest-help

php-general Digest 26 Jul 2013 09:18:07 - Issue 8310

Topics (messages 321704 through 321715):

Re: What wrong am I doing now?
321704 by: Karl-Arne Gjersøyen
321705 by: Matijn Woudt
321706 by: Sebastian Krebs
321707 by: Jim Giner
321708 by: Matijn Woudt
321709 by: Jim Giner

Quick Q.
321710 by: Richard Quadling
321711 by: Matijn Woudt
321713 by: Richard Quadling
321714 by: Matijn Woudt

Re: COM - Assigning to method.
321712 by: Richard Quadling

From 24/7/2013 to 2013-07-24
321715 by: Karl-Arne Gjersøyen

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
http://www.php.net/manual/en/datetime.format.php have the solution. Sorry
for asking before I look at php.net!!!

Karl

-- Forwarded message --
From: Karl-Arne Gjersøyen karlar...@gmail.com
Date: 2013/7/24
Subject: What wrong am I doing now?
To: PHP Mailinglist php-gene...@lists.php.net


mysql SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;
+---+
| DATE_FORMAT(dato, '%e-%c-%Y') |
+---+
| 24-7-2013 |
| 23-7-2013 |
+---+
2 rows in set (0.00 sec)

mysql


// My PHP code looks like this.
// -
$sql = SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;
$resultat = mysql_query($sql, $tilkobling) or die(mysql_error());

while($rad = mysql_fetch_array($resultat)){
$dato = $rad['dato'];
var_dump($dato);

I gott NULL,NULL here and believe it is something with my PHP Source that
is wrong when using DATE_FORMAT. As you see above it work in terminal.

I hope this not is off-topic for the list. If so, I am sorry for it and
hope you can give me advice about a good MySQL list for newbie's.

Thanks again for your help!

Karl
---End Message---
---BeginMessage---
On Wed, Jul 24, 2013 at 2:19 PM, Karl-Arne Gjersøyen karlar...@gmail.comwrote:

 mysql SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
 dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;
 +---+
 | DATE_FORMAT(dato, '%e-%c-%Y') |
 +---+
 | 24-7-2013 |
 | 23-7-2013 |
 +---+
 2 rows in set (0.00 sec)

 mysql


 // My PHP code looks like this.
 // -
 $sql = SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
 dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;
 $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());

 while($rad = mysql_fetch_array($resultat)){
 $dato = $rad['dato'];


$rad['dato'] probably doesn't exist because you used DATE_FORMAT.
Either use $rad[0], or use the following SQL:

$sql = SELECT DATE_FORMAT(dato, '%e-%c-%Y') AS dato FROM transportdokument
WHERE dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;

Regards,

Matijn
---End Message---
---BeginMessage---
Hi,

Just want to mention: ext/mysel is deprecated. Use MySQLi, or PDO_MYSQL
instead. :)

Regards,
Sebastian


2013/7/24 Karl-Arne Gjersøyen karlar...@gmail.com

 http://www.php.net/manual/en/datetime.format.php have the solution. Sorry
 for asking before I look at php.net!!!

 Karl

 -- Forwarded message --
 From: Karl-Arne Gjersøyen karlar...@gmail.com
 Date: 2013/7/24
 Subject: What wrong am I doing now?
 To: PHP Mailinglist php-gene...@lists.php.net


 mysql SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
 dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;
 +---+
 | DATE_FORMAT(dato, '%e-%c-%Y') |
 +---+
 | 24-7-2013 |
 | 23-7-2013 |
 +---+
 2 rows in set (0.00 sec)

 mysql


 // My PHP code looks like this.
 // -
 $sql = SELECT DATE_FORMAT(dato, '%e-%c-%Y') FROM transportdokument WHERE
 dato = '2013-07-20' AND dato = '2013-07-24' GROUP BY dato DESC;
 $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());

 while($rad = mysql_fetch_array($resultat)){
 $dato = $rad['dato'];
 var_dump($dato);

 I gott NULL,NULL here and believe it is something with my PHP Source that
 is wrong when using DATE_FORMAT. As you see above it work in terminal.

 I hope this not is off-topic for the list. If so, I am sorry for it and
 hope you can give me advice about a good 

php-general Digest 26 Jul 2013 21:29:46 -0000 Issue 8311

2013-07-26 Thread php-general-digest-help

php-general Digest 26 Jul 2013 21:29:46 - Issue 8311

Topics (messages 321716 through 321725):

Re: From 24/7/2013 to 2013-07-24
321716 by: Přemysl Fiala
321717 by: Karl-Arne Gjersøyen
321718 by: Jim Giner
321719 by: Jim Giner
321720 by: Alejandro Michelin Salomon
321721 by: jomali
321722 by: Robert Cummings
321723 by: jomali
321724 by: Alejandro Michelin Salomon
321725 by: Robert Cummings

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---

Hello,

try  - reference

 foreach($lagret_dato as $dag) or something like this :-)

Premek.

On Fri, 26 Jul 2013 11:18:03 +0200, Karl-Arne Gjersøyen  
karlar...@gmail.com wrote:



Below is something I try that ofcourse not work because of rsosort.
Here is my code:
---
$lagret_dato = $_POST['lagret_dato'];
foreach($lagret_dato as $dag){

$dag = explode(/, $dag);
   rsort($dag);
$dag = implode(-, $dag);
var_dump($dag);

What I want is a way to rewrite contents of a variable like this:

From 24/7/2013 to 2013-07-24

Is there a way in PHP to do this?

Thank you very much.

Karl


---End Message---
---BeginMessage---
2013/7/26 Davi Marcondes Moreira davi.marcondes.more...@gmail.com

 Hi! I suggest you to try this:

 $foo = DateTime::createFromFormat('d/m/Y');
 $newDate = $foo-format('Y-m-d');



Thank you veyr much. With a small modification this work perfec!

Karl


  Em 26/07/2013 09:19, Karl-Arne Gjersøyen karlar...@gmail.com
 escreveu:

 Below is something I try that ofcourse not work because of rsosort.
 Here is my code:
 ---
 $lagret_dato = $_POST['lagret_dato'];
 foreach($lagret_dato as $dag){

 $dag = explode(/, $dag);
rsort($dag);
 $dag = implode(-, $dag);
 var_dump($dag);

 What I want is a way to rewrite contents of a variable like this:

 From 24/7/2013 to 2013-07-24

 Is there a way in PHP to do this?

 Thank you very much.

 Karl


---End Message---
---BeginMessage---
I think you should change from using 'rsort' ( a SORT function) to 
'array_reverse', a simple reverse function.

Your example of what you desire is wrong.
24-7-2013 will give you the 2013-24-7 that you want.
Here is my sample code.  Try it yourself.

?
$dag = array(24/7/2013);
echo Began with: ;var_dump( $dag);
echo br**br;
echo Try using rsortbr;
$dagparts = explode(/,$dag[0]);
echo dagparts: ;
var_dump($dagparts);
echo br**br;
rsort($dagparts);
echo sorted dagparts: ;
var_dump($dagparts);
echo br**br;
$newdag = implode(-,$dagparts);
echo newdag: ;
var_dump($newdag);
echo br**br;
echo Now use array_reversebr;
$dagparts = explode(/,$dag[0]);
echo dagparts: ;
var_dump($dagparts);
echo br**br;
$dagparts = array_reverse($dagparts);
echo REVERSED dagparts: ;
var_dump($dagparts);
echo br**br;
$newdag = implode(-,$dagparts);
echo newdag: ;
var_dump($newdag);
echo br**br;

---End Message---
---BeginMessage---

On 7/26/2013 10:10 AM, Jim Giner wrote:

I think you should change from using 'rsort' ( a SORT function) to
'array_reverse', a simple reverse function.
Your example of what you desire is wrong.
24-7-2013 will give you the 2013-24-7 that you want.


oops.
I meant to say will NOT give you the 2013-2407 that you want.

---End Message---
---BeginMessage---
Use this:

echo preg_replace('#(\d{2})/(\d{2})/(\d{4})#' , \\3-\\2-\\1, '24/07/2013'
); RESULT = 2013-07-24

Alejandro M.S


-Mensagem original-
De: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Enviada em: sexta-feira, 26 de julho de 2013 11:12
Para: php-gene...@lists.php.net
Assunto: Re: [PHP] From 24/7/2013 to 2013-07-24

On 7/26/2013 10:10 AM, Jim Giner wrote:
 I think you should change from using 'rsort' ( a SORT function) to 
 'array_reverse', a simple reverse function.
 Your example of what you desire is wrong.
 24-7-2013 will give you the 2013-24-7 that you want.

oops.
I meant to say will NOT give you the 2013-2407 that you want.


--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


---End Message---
---BeginMessage---
On Fri, Jul 26, 2013 at 5:18 AM, Karl-Arne Gjersøyen karlar...@gmail.comwrote:

 Below is something I try that ofcourse not work because of rsosort.
 Here is my code:
 ---
 $lagret_dato = $_POST['lagret_dato'];
 foreach($lagret_dato as $dag){

 $dag = explode(/, $dag);
rsort($dag);
 $dag = implode(-, $dag);
 var_dump($dag);

 What I want is a way to rewrite contents of a variable like this:

 From 24/7/2013 to 2013-07-24

 Is there a way in PHP to do this?

 Thank