This topic is locked

Date and Time formatted

3/2/2008 8:01:42 AM
PHPRunner General questions
R
rainerwolf author

Hello,
i want to format automtically a short date field with points as follows:
Input must be possible as ddmmyyyy or ddmmyy or dd.mm.yyyy. Is it possible to format this field automatically with points after dd and mm?
In the moment i have declared this field as short date in phprunner, and when i filled up with ddmmyyyy i get 00.00.0000.
Thanks for help.
Rainer

J
Jane 3/3/2008

Hi,
you need to convert entered value to correct format in the Before record added/Before record updated events on the Events tab.

R
rainerwolf author 3/3/2008

Hi,

you need to convert entered value to correct format in the Before record added/Before record updated events on the Events tab.

R
rainerwolf author 3/3/2008




Hi Jane,

please can you give me the solution for the right converting syntax?
Rainer

R
rainerwolf author 3/3/2008

Jane,

another problem: when i type a date in dd.mm.yy (25.02.55), german calendar i get the year not as 1955, i get it as 2055

J
Jane 3/3/2008

Rainer,
here is a sample:

if (strpos($values["FieldName"],"."))

{

$arr = explode(".",$values["FieldName"]);

$day = $arr[0];

$month = $arr[1];

$year = $arr[2];
if (strlen($arr[2])==2)

$year = "19".$arr[2];
$str = $day.".".$month.".".$year;

}

else

{

$day = substr($values["FieldName"],0,2);

$month = substr($values["FieldName"],2,2);

$year = substr($values["FieldName"],4);
$str = $day.".".$month.".".$year;

}

R
rainerwolf author 3/3/2008

Rainer,

here is a sample:


Hi Jane,
this is my code:
if (strpos($values["Geburtsdatum"],"."))

{

$arr = explode(".",$values["Geburtsdatum"]);

$day = $arr[0];

$month = $arr[1];

$year = $arr[2];
if (strlen($arr[2])==2)

$year = "19".$arr[2];
$str = $day.".".$month.".".$year;

}

else

{

$day = substr($values["Geburtsdatum"],0,2);

$month = substr($values["Geburtsdatum"],2,2);

$year = substr($values["Geburtsdatum"],4);
$str = $day.".".$month.".".$year;

}

echo $values["Geburtsdatum"];
I get the following error:
Column ' Geburtsdatum ' cannot be null

J
Jane 3/4/2008

Rainer,
check value of Geburtsdatum before:

if ($values["Geburtsdatum"])

if (strpos($values["Geburtsdatum"],"."))

{

...

}

R
rainerwolf author 3/4/2008

Rainer,

check value of Geburtsdatum before:


Jane,
i have check it, Geburtsdatum is empty. I have declared the field in my table as date with standard 0000-00-00. Is this correct?

J
Jane 3/4/2008

Hi,
you can declare field as you want in the database.

You only need to check values in the PHP code before.

If value is empty you don't need to change it. That's all.