Last active
November 23, 2023 14:44
-
-
Save victory-sokolov/ad354bda02a07eea5a133d2859b4a334 to your computer and use it in GitHub Desktop.
Convert Date to char array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment