Convert text to mysql date format
Convert text to mysql date format
am 16.01.2007 19:53:55 von hennie
How can i convert a date in text format into a date format that is accepted
by msql?
I have 3 values for day, month and year
I combine them to a date string $date1=$year."-".$month."-".$day;
How do i go further to make $date1 suitable for mysql?
Thanks in advance, Hennie
Re: Convert text to mysql date format
am 17.01.2007 11:33:19 von Captain Paralytic
hennie wrote:
> How can i convert a date in text format into a date format that is accepted
> by msql?
>
> I have 3 values for day, month and year
>
> I combine them to a date string $date1=$year."-".$month."-".$day;
>
> How do i go further to make $date1 suitable for mysql?
>
> Thanks in advance, Hennie
Could you possibly reveal what format the data in the variables is in?
If year looks like 2006
and month looks like 05
and day looks like 09
then you are done.
Re: Convert text to mysql date format
am 17.01.2007 11:53:59 von Captain Paralytic
hennie wrote:
> How can i convert a date in text format into a date format that is accepted
> by msql?
>
> I have 3 values for day, month and year
>
> I combine them to a date string $date1=$year."-".$month."-".$day;
>
> How do i go further to make $date1 suitable for mysql?
>
> Thanks in advance, Hennie
Could you possibly reveal what format the data in the variables is in?
If year looks like 2006
and month looks like 05
and day looks like 09
then you are done.
Re: Convert text to mysql date format
am 19.01.2007 19:27:14 von unknown
Post removed (X-No-Archive: yes)
Re: Convert text to mysql date format
am 11.03.2007 07:06:25 von Christopher Ames
Try using the PHP strtotime() function to make a UNIXTIME date, then convert
from that on the MySql side using FROMUNIXTIME (or something). StrToTime()
is a great function. Get something close to a date format and it uses it.
On 1/16/07 10:53, in article 7174d$45ad1f4a$3ec25048$9670@news.chello.nl,
"hennie" wrote:
> How can i convert a date in text format into a date format that is accepted
> by msql?
>
> I have 3 values for day, month and year
>
> I combine them to a date string $date1=$year."-".$month."-".$day;
>
> How do i go further to make $date1 suitable for mysql?
>
> Thanks in advance, Hennie
>
>
Re: Convert text to mysql date format
am 11.03.2007 22:51:32 von fox.whisper
>On 1/16/07 10:53, in article 7174d$45ad1f4a$3ec25048$9670@news.chello.nl,
>"hennie" wrote:
>
>> How can i convert a date in text format into a date format that is accepted
>> by msql?
>>
>> I have 3 values for day, month and year
>>
>> I combine them to a date string $date1=$year."-".$month."-".$day;
>>
>> How do i go further to make $date1 suitable for mysql?
>>
>> Thanks in advance, Hennie
>>
>>
>
As long as your input is numerical, you've just done it!
Re: Convert text to mysql date format
am 13.03.2007 23:39:56 von G-Rod
I use this for standard dates (e.g. 12-21-07)
function changeToMySqlDate($caldate){
if($caldate == ""){
return "1969-12-31";
} else {
$caldate = date('Y-m-d', strtotime($caldate));
return $caldate;
}
}
On Mar 11, 2:51 pm, fox.whis...@virgin.net wrote:
> >On 1/16/07 10:53, in article 7174d$45ad1f4a$3ec25048$9...@news.chello.nl,
> >"hennie" wrote:
>
> >> How can i convert a date in text format into a date format that is accepted
> >> by msql?
>
> >> I have 3 values for day, month and year
>
> >> I combine them to a date string $date1=$year."-".$month."-".$day;
>
> >> How do i go further to make $date1 suitable for mysql?
>
> >> Thanks in advance, Hennie
>
> As long as your input is numerical, you've just done it!