Format std::time output

You can use the crate chrono to achieve the same result: extern crate chrono; use chrono::Local; fn main() { let date = Local::now(); println!(“{}”, date.format(“%Y-%m-%d][%H:%M:%S”)); } Edit: The time crate is not deprecated: it is unmaintained. Besides, it is not possible to format a time using only the standard library.

get time and date by NSDate

NSDate *localDate = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; dateFormatter.dateFormat = @”MM/dd/yy”; NSString *dateString = [dateFormatter stringFromDate: localDate]; NSDateFormatter *timeFormatter = [[NSDateFormatter alloc]init]; timeFormatter.dateFormat = @”HH:mm:ss”; NSString *dateString = [timeFormatter stringFromDate: localDate]; There are many many different ways to represent the date and time so check NSDateFormatter for more info.

Rounding up to nearest 30 minutes in Python

To round up to the nearest 30 minutes: #!/usr/bin/env python3 from datetime import datetime, timedelta def ceil_dt(dt, delta): return dt + (datetime.min – dt) % delta now = datetime.now() print(now) print(ceil_dt(now, timedelta(minutes=30))) The formula is suggested by @Mark Dickinson (for a different question). Output 2015-09-22 19:08:34.839915 2015-09-22 19:30:00 Note: if the input is timezone-aware datetime … Read more

Display a countdown for the python sleep function

you could always do #do some stuff print ‘tasks done, now sleeping for 10 seconds’ for i in xrange(10,0,-1): time.sleep(1) print i This snippet has the slightly annoying feature that each number gets printed out on a newline. To avoid this, you can import sys import time for i in xrange(10,0,-1): sys.stdout.write(str(i)+’ ‘) sys.stdout.flush() time.sleep(1)

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)