Jump to content

Changing Date from 20021125 to 11/25/2002

This topic is 7106 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Well, I know this isn't the PHP forum, but I just did this yesterday using PHP so it's still fresh in my mind if you happen to know PHP and want to reformat the data before importing it into FileMaker. Here's my code for reformatting a field called $whenmodified... you'll have to loop it in an array or something to convert all your records and you won't need the time portion.

$year = substr ($whenmodified, 0, 4);

$month = substr ($whenmodified, 4, 2);

$day = substr ($whenmodified, 6, 2);

$hour = substr ($whenmodified, 8, 2);

$min = substr ($whenmodified, 10, 2);

$sec = substr ($whenmodified, 12, 2);

$whenmodified_epochtime = mktime($hour, $min, $sec, $month, $day, $year);

$whenmodified_date = date ("m/d/Y", $whenmodified_epochtime);

$whenmodified_time = date ("g:i:s a", $whenmodified_epochtime);


I was actually converting a MySQL timestamp (date and time jammed together with no delimiters in a yyyymmddhhmmss format). I split the string into 2 parts into more FM-like modification date and modification time fields using PHP's date() function, but date() only works on datetimes stored as a single integer referred to as UNIX EPOCH TIME. I could have manually concatenated the fields once I had them split, e.g.

$whenmodified_date = $month . "/" . $day . "/" . $year;

and I originally did so, but the date() function allows greater flexibility for formatting for both dates and times so I used it instead.


Link to comment
Share on other sites

Thanks by creating a new Calculation field named "right date" that looks like this is the field when the wrong date field is called "wrong":

Date(Middle(wrong,5,2),Right(wrong,2),Left(wrong,4)) and then make the out put a Date type. It works.

If you make a copy of the main file and then make this new Calc. field. Then do the import into the copy file so that the date changes, then import this info to the original file but change the routing from the calc. field to the main file date field. easy.


Link to comment
Share on other sites

This topic is 7106 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.