
![]() |
thedarkness
Gonna put this in here because there is no C++ code repository (perk?
![]() Just wrote this. It's trivial but it may help someone and I was interested in the use of iomanip which, surprisingly, I haven't realy delved into before. This prints yesterday's (now - 86400 seconds) date, formatted as I wanted it, could easily be modified to perform a lot of date related tasks........ #include <time.h> #include <iostream> #include <iomanip> // For formatting output using namespace std; int main( void ) { time_t now; struct tm * timeinfo; time( &now ); now -= 86400; // Seconds in a day timeinfo = localtime( &now ); cout << setfill('0' ) << setw( 2 ) << timeinfo->tm_mday << " " << setw( 2 ) << timeinfo->tm_mon + 1 << " " << setw( 2 ) << timeinfo->tm_year - 100 << endl; } Cheers, td perkiset
I just put one in and am delighted TD - didn't think anyone would still be using those <>dinosaurs> languages anymore such that we'd need one
:grabs helmet, dives into foxhole: Please post this there - nice one! /p thedarkness
![]() |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads