w3resource

Python Arrow Module: Get date and time properties from datetime function using arrow module

Arrow Module: Exercise-7 with Solution

Write a Python program to get date and time properties from datetime function using arrow module.

Sample Solution:

Python Code:

import arrow
a = arrow.utcnow()
print("Current date:")
print(a.date())
print("\nCurrent time:")
print(a.time())

Sample Output:

Current date:
2019-06-01

Current time:
08:48:13.230800

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to extract year, month and date value from current datetime using arrow module.
Next: Write a Python program to replace hour, minute, day, month, year and timezone with specified value of current datetime using arrow.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz



Python: Tips of the Day

Python: How to make a chain of function decorators?

from functools import wraps

def makebold(fn):
    @wraps(fn)
    def wrapped(*args, **kwargs):
        return "<b>" + fn(*args, **kwargs) + "</b>"
    return wrapped

def makeitalic(fn):
    @wraps(fn)
    def wrapped(*args, **kwargs):
        return "<i>" + fn(*args, **kwargs) + "</i>"
    return wrapped

@makebold
@makeitalic
def hello():
    return "hello world"

@makebold
@makeitalic
def log(s):
    return s

print hello()        # returns "<b><i>hello world</i></b>"
print hello.__name__ # with functools.wraps() this returns "hello"
print log('hello')   # returns "<b><i>hello</i></b>"

Ref: https://bit.ly/3cVz5iw