viktor
10/25/2017 - 5:00 AM

Convert Date to char array

Convert Date to char array

char buff[100];
    if(ptm->tm_mon < 10){
            if(ptm->tm_mday < 10){
                    sprintf(buff,"%u-0%u-0%u",(unsigned)ptm->tm_year,(unsigned)ptm->tm_mon,(unsigned)ptm->tm_mday);
            }else{
                    sprintf(buff,"%u-0%u%u",(unsigned)ptm->tm_year,(unsigned)ptm->tm_mon,(unsigned)ptm->tm_mday);
            }
    }else{
            if(ptm->tm_mday < 10){
                    sprintf(buff,"%u-%u-0%u",(unsigned)ptm->tm_year,(unsigned)ptm->tm_mon,(unsigned)ptm->tm_mday);
            }else{
                    sprintf(buff,"%u-%u-%u",(unsigned)ptm->tm_year,(unsigned)ptm->tm_mon,(unsigned)ptm->tm_mday);
            }
    }