Bluehost.com Web Hosting $6.95

quick question

This is a discussion on quick question within the PHP General forums, part of the PHP Programming Forums category; Hi Ho to read date from HTML form -> How to read $_POST['date']="dd/mm/YYYY" string ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-09-2008
Merca, Ansta Ltd
 
Posts: n/a
Default quick question

Hi

Ho to read date from HTML form ->
How to read $_POST['date']="dd/mm/YYYY" string variable as a date?
Reply With Quote
  #2 (permalink)  
Old 05-09-2008
Richard Heyes
 
Posts: n/a
Default Re: [PHP] quick question

> Ho to read date from HTML form ->
> How to read $_POST['date']="dd/mm/YYYY" string variable as a date?


If you want a unix timestamp then try investigating strtotime().

--
Richard Heyes

+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
Reply With Quote
  #3 (permalink)  
Old 05-09-2008
Thiago Pojda
 
Posts: n/a
Default RES: [PHP] quick question

What do you mean read a string as a date, a date object?

Atenciosamente,

www.softpartech.com.br


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda@softpartech.com.br
Excelência em Softwares Financeiros


-----Mensagem original-----
De: Merca, Ansta Ltd [mailto:merca@ansta.co.uk]
Enviada em: sexta-feira, 9 de maio de 2008 06:36
Para: php-general@lists.php.net
Assunto: [php] quick question

Hi

Ho to read date from HTML form ->
How to read $_POST['date']="dd/mm/YYYY" string variable as a date?

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




Reply With Quote
  #4 (permalink)  
Old 05-09-2008
Richard Heyes
 
Posts: n/a
Default Re: [PHP] quick question

> Well, when I try date('d/m/y', strtotime($_POST('date')) - it seems
> mixing day and month, I tried setlocale(LC_ALL, 'en_GB'); but it didn't


strtotime() returns a unix timestamp (ie number of seconds since
1970ish. Nothing to do with the date object.

--
Richard Heyes

+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
Reply With Quote
  #5 (permalink)  
Old 05-09-2008
Stut
 
Posts: n/a
Default Re: [PHP] quick question

>>
>> Well, when I try date('d/m/y', strtotime($_POST('date')) - it seems
>> mixing day and month, I tried setlocale(LC_ALL, 'en_GB'); but it
>> didn't


If you're sure that's the format of the date, this will do it...

list($day, $month, $year) = explode('/', $thedate);
$thetimestamp = mktime(0, 0, 0, $month, $day, $year);

-Stut

--
http://stut.net/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:24 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0