Python time module ⌚

Поделиться
HTML-код
  • Опубликовано: 21 окт 2024

Комментарии • 65

  • @BroCodez
    @BroCodez  3 года назад +28

    # ***************************************************************************
    import time
    # ***************************************************************************
    print(time.ctime(0)) # convert a time expressed in seconds since epoch to a readable string
    # epoch = when your computer thinks time began (reference point)
    print(time.time()) # return current seconds since epoch
    print(time.ctime(time.time())) # will get current time
    # ***************************************************************************
    # time.strftime(format, time_object) = formats a time_object to a string
    # time_object = time.localtime() # local time
    # time_object = time.gmtime() # UTC time
    # local_time = time.strftime("%B %d %Y %H:%M:%S", time_object)
    # print(local_time)
    # ***************************************************************************
    # time.strptime(time_string, format) = parses a string representing time/date and returns a struct_time object
    # time_string = "20 April, 2020"
    # time_object = time.strptime(time_string,"%d %B, %Y")
    # print(time_object)
    # ***************************************************************************
    # time.asctime(time_tuple) = accepts a time_object or a tuple up to 9 elements and returns a string
    # (year, month, day, hours, minutes, secs, day of the week, day of the year, dst)
    # time_tuple = (2020, 4, 20, 4, 20, 0, 0, 0, 0)
    # time_string = time.asctime(time_tuple)
    # print(time_string)
    # ***************************************************************************
    # time.asctime(time_tuple) = accepts a time_object or a tuple up to 9 elements and return seconds since epoch
    # (year, month, day, hours, minutes, secs, day of the week, day of the year, dst)
    # time_tuple = (2020, 4, 20, 4, 20, 0, 0, 0, 0)
    # time_string = time.mktime(time_tuple)
    # print(time_string)
    # ***************************************************************************

  • @farhan8834
    @farhan8834 2 года назад +9

    The generosity I feel when I copy your neat and clean code with proper comments is too amazing, GREAT QUALITY CONTENT !!❤

  • @jhassee
    @jhassee Год назад +9

    I paid for courses and didn't learn anything, this guy an maybe 4 others on RUclips taught me the ins and outs of python. Paying is not always the answer as I've learned

    • @cr1azak
      @cr1azak Год назад +2

      Can you tell me names of the other 4 channels please.

    • @aureliano_37
      @aureliano_37 10 месяцев назад +3

      Who are the 4 others?

  • @lukascampidell9376
    @lukascampidell9376 8 месяцев назад +1

    I don't use the time module that often, so this was very helpful!

  • @kube4202
    @kube4202 2 года назад +6

    bro, You helped me more than my teacher did, so much love

  • @SouravDash-di3vj
    @SouravDash-di3vj 3 месяца назад

    that's really help me bro to understand the basic things of time module keep going on like this

  • @lordrobertclive-vc5ld
    @lordrobertclive-vc5ld Месяц назад +1

    time() Returns the current time in seconds since the Epoch.
    sleep(seconds) Pauses execution for the given number of seconds.
    ctime([seconds]) Converts seconds since the Epoch to a string representing local time.
    strftime(format) Converts struct_time to a string according to the given format.
    localtime([secs]) Converts seconds to struct_time in local time.
    gmtime([secs]) Converts seconds to struct_time in UTC.
    mktime(t) Converts struct_time to seconds since the Epoch.
    perf_counter() High-resolution performance counter for measuring elapsed time.
    monotonic() Monotonic clock for time measurement.
    time_ns() Current time in nanoseconds since the Epoch.

  • @WhishoMH
    @WhishoMH Год назад +2

    this was actually uselfull, thanks for the eforts! you solved the complete misundertanding I had with that python documentation really. < 3

  • @carterjackson7460
    @carterjackson7460 3 года назад +16

    perfect timing :)

    • @oldplagu3
      @oldplagu3 2 года назад +1

      hahah good one

  • @amf-z7x
    @amf-z7x 11 месяцев назад +1

    الشرح ممتاز =)

  • @mendozosa
    @mendozosa 2 года назад +1

    This tutorial has been the only one that help me with the time module cause the other codes didn't run at all, just gave me traceback errors, I'm trying to figure out the time and dates syntax

    • @mo-ab7315
      @mo-ab7315 11 месяцев назад

      hows the programming life ?

    • @shasvat0
      @shasvat0 10 месяцев назад

      @@mo-ab7315 you tell me

  • @lw9954
    @lw9954 2 года назад +2

    TY BRO

  • @kellarin
    @kellarin 2 года назад +1

    Why are our epoch times identical! I'm not even kidding. That's kind of spooky.

  • @cristiucvladimir7909
    @cristiucvladimir7909 5 месяцев назад +1

    Thanks bro!

  • @7even255
    @7even255 2 года назад

    I love how your example for the tuple is 4/20 at 4:20am

  • @kindasus-pn2lr
    @kindasus-pn2lr 2 месяца назад

    🔥

  • @suman_sourav
    @suman_sourav 10 месяцев назад

    liked it. and subscribed

  • @varunahlawat9013
    @varunahlawat9013 11 месяцев назад

    simply neat

  • @ilordepic
    @ilordepic 2 года назад

    another comment for the algorithm bro thanks a lot

  • @mohmedmohmed7399
    @mohmedmohmed7399 9 месяцев назад

  • @ummanmemmedov
    @ummanmemmedov Год назад

    Excellent!

  • @chrisdavies6221
    @chrisdavies6221 2 года назад +1

    Hey Bro, loving the tutorials.
    Can I ask what would be a use for referencing the epoch time?

  • @calsbergus
    @calsbergus Год назад

    Very good tutorial!

  • @Baekhyuneeslove
    @Baekhyuneeslove 5 месяцев назад

    thanks for help

  • @LimeSpeedCrystal
    @LimeSpeedCrystal Год назад

    My chat with a bot now can tell the time! Thank you!

  • @bekturasanbekov1979
    @bekturasanbekov1979 Год назад

    thx 4 vid bro !

  • @piotrkopcewicz5227
    @piotrkopcewicz5227 Год назад

    god is time thx as always !!!!

  • @wmstram1
    @wmstram1 Год назад

    Watched it. Think Python could have made this a lot more elegant.

  • @shaktibal5121
    @shaktibal5121 2 года назад

    So much better than reading - thanks

  • @PlusUltraNerdO-O
    @PlusUltraNerdO-O Месяц назад

    Thanks

  • @SuperStarEevee
    @SuperStarEevee 2 года назад

    Thank you!

  • @EissaAlahdul
    @EissaAlahdul 2 года назад

    شكرا

  • @beingzero7541
    @beingzero7541 2 года назад

    Wow!

  • @saikokun541
    @saikokun541 2 года назад

    Awesome

  • @gingercholo
    @gingercholo 2 года назад

    Yo bro this was great

  • @nukhbaiqbal7798
    @nukhbaiqbal7798 3 года назад +1

    Hey, Is there some way to ask user to enter a line but within a time limit in python I mean for example there is only 10s to write a line by user and if he didn't write within 10s the program says TIME IS OVER.

  • @onurdogan2390
    @onurdogan2390 2 года назад

    yo amazing

  • @uuhju7004
    @uuhju7004 3 года назад

    ty

  • @provokator-provocateur7603
    @provokator-provocateur7603 3 года назад +3

    mktime() ? mortal kombat time? Well that's my favorite time.

  • @HussainAli-sb1dv
    @HussainAli-sb1dv 11 месяцев назад

    love u

  • @snowhe7208
    @snowhe7208 2 года назад

    Nice

  • @ruhaprpl
    @ruhaprpl Год назад

    Bro

  • @joyedet1363
    @joyedet1363 2 года назад +1

    Mine rad Thu Jan 01:00:00 1970
    How about yours?🔥🤩

  • @hameeeed5992
    @hameeeed5992 Год назад

    :)

  • @murilosilvestre7736
    @murilosilvestre7736 3 года назад +1

    our epoch time are only 5 hours away from each other :D

  • @Adamelamine
    @Adamelamine 2 года назад

    Drop a comment down below

  • @TigerBros
    @TigerBros 10 месяцев назад

    How can I fix the perf_counter it's giving high values that isn't true

  • @gustavoaponte1814
    @gustavoaponte1814 Год назад

    meow~! ^o^

  • @shasvat0
    @shasvat0 10 месяцев назад

    at 4:00

  • @kyu2813
    @kyu2813 11 месяцев назад

    Is that how you pronounce epoch?? Lol I've been pronouncing it as ee-pock my whole life

  • @jhassee
    @jhassee Год назад

    so it is not apparent that bro smokes the devils lettuce hahahaha

  • @aureliano_37
    @aureliano_37 10 месяцев назад

    Where's the code?

  • @francisfigueroaiii5383
    @francisfigueroaiii5383 Год назад

    g

  • @Akxperto7
    @Akxperto7 Год назад

    currently daylight savings time is on and when i pass time.gmtime(), it shows tm_isdst=0. it shows the time accurate to minute but just an hour offto make up for the daylight savings time

  • @jamshidkushbaev2873
    @jamshidkushbaev2873 Год назад

    bro, You helped me more than my teacher did, so much love

  • @rubenc4696
    @rubenc4696 5 месяцев назад

    Thanks

  • @Amir_Plays_non_stop
    @Amir_Plays_non_stop 3 года назад

    Nice