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 not usable #171

Open
vgout69 opened this issue Jan 12, 2021 · 1 comment
Open

Date not usable #171

vgout69 opened this issue Jan 12, 2021 · 1 comment

Comments

@vgout69
Copy link

vgout69 commented Jan 12, 2021

Hello,

I'm really sorry this post could be due to my lack of experience in using dates but, I can't retrieve ccorrect date from the CSV files I'm using.
Dates are with this format mm/dd/YYYY and displayed with Excel as mm.dd.YYYY.
When I go through my rows, I have int values displayed (44205) that can only be formated as 01/01/1970 with what I'm used to use as php functions.
Can you please help me ?

Thank you very much.

@SimonAnnetts
Copy link

Try this function to convert the integer (number of days since 30 Dec 1899) to a date with format YYYY-MM-DD

    //convert excel day since 30 dec 1899 to a date
    function convert_from_excel_date($edate) {
        if(!preg_match('/^[0-9]+$/',$edate)) return '0000-00-00';
        return date('Y-m-d', ($edate-25569)*86400);
    }

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

2 participants