php3-list | 199903
Date: 03/23/99
- Next message: Heads Together Systems - Steve Farmer: "Re: [PHP3] forcing php to start another page."
- Previous message: Rasmus Lerdorf: "Re: [PHP3] Feature request: GetImageSize for file pointers, variables"
- In reply to: a. otto: "[PHP3] date/time problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 23 Mar, a. otto wrote:
> hello,
>
> time has come that i have again some problems ;-)
>
> i have a form on a website where people can login and logout and
> describe what they are doing.
>
> in two of the formfields the current date (23.03.1999) and time
> (07:18:12) is shown. to make it more difficult the user can change the
> settings and use whatever time and date he wants. so i pass it to
> another page which inserts the settings to a datbase.
>
> whenever i select these informations form the database i get the
> following information out of the m$-access database:
> date: 23.03.1999 00:00:00
> time: 01.01.1899 07:18:12
>
> so i decided to convert the date and time variables to unix-timestamp
> and there is my problem. i don't know how...
>
> it's no problem for me anymore to convert date to timestamp but i have a
> variable here which contents a string and i really don't know how to
> solve this problem.
>
You could use one of the string handling functions to break those
strings down to year, month, day, hour, minute and second values; then
feed those values to mktime() to get your unix timestamp. For example,
if you know that the date will always be in the format dd.mm.yyyy you
could use substr to get the day, month and year values. Using your
example:
$msdate = "23.03.1999 00:00:00";
$day = substr($msdate,0,2);
$month = substr($msdate,3,2);
$year = substr($msdate,6,4);
This assumes that the first character of the string is 0!! I haven't
tested this.
Cheers
-- David RobleyWEBMASTER | Phone +61 8 8374 0970 RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA Visit the PHP mirror at http://au.php.net:81/
-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>
- Next message: Heads Together Systems - Steve Farmer: "Re: [PHP3] forcing php to start another page."
- Previous message: Rasmus Lerdorf: "Re: [PHP3] Feature request: GetImageSize for file pointers, variables"
- In reply to: a. otto: "[PHP3] date/time problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

