Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date format #44

Closed
gadget00 opened this issue Apr 25, 2017 · 3 comments
Closed

Date format #44

gadget00 opened this issue Apr 25, 2017 · 3 comments

Comments

@gadget00
Copy link

Hi; I want to thank you for this amazing code. It's helping me a LOT.

However, I'm having problems with fields that are of DATE data type. Somehow instead of getting them in php as "04/31/2017" when I use it (and the actual foxpro DBF table has it saved in this format) I receive "Wednesday, April 31 2017 00:00:01".

How do I set up the date format when receiving the value from the DBF?

Thank you

@nebojsac
Copy link

nebojsac commented Apr 26, 2017

I believe it just takes it directly from the DBF data. In PHP you can handle it like this:

<?php
$parsed = date_parse($dateString); //$dateString is the result from php-xbase
$formatted = sprintf('%04d/%02d/%02d', $parsed['day'],  $parsed['month'], $parsed['year']);

@gadget00
Copy link
Author

gadget00 commented Aug 3, 2017

Hi again! I figured out that the php-xbase took the actual "date" value from the DBF and transformed it into a unix timestamp by default. What I did is take that default unix stamp and format it as I needed:

$unix_time = $record->getDate('fecnacim'); $nacimiento = date("Y-m-d",$unix_time);

@gadget00 gadget00 closed this as completed Aug 3, 2017
@luads
Copy link
Owner

luads commented Aug 3, 2017

👍 👍 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants