Flutter Tutorial for Beginners #27 - World Time API

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

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

  • @algeriennesaffaires7017
    @algeriennesaffaires7017 4 года назад +108

    4:50 i swear you did that mistake on purpose to show us what could happen and explain to us the best way, you are a master in teaching

  • @tyson3381
    @tyson3381 4 года назад +66

    Need a teacher like you.
    You are the Best.
    This can be the best programming channel on youtube.

    • @NetNinja
      @NetNinja  4 года назад +3

      Thanks! 😃 Glad you like!

    • @hank91918
      @hank91918 4 года назад +3

      Correction, this IS the best programming channel on youtube.

  • @mehmet-kp5uj
    @mehmet-kp5uj 3 года назад +76

    SOLUTIONS OF ERRORS
    1. http error(Unhandled Exception: Bad state: Insecure HTTP is not allowed by platform): write https instead of http
    2. Uri error: get(Uri.parse("https:..."));
    3. for +/- error(wrong hours for negative timezones): substring(0,3) instead of (1,3)

    • @itiah509
      @itiah509 2 года назад +3

      Excellent!

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

      Thanks bro! Keep helping!

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

      can you help me with some other errors, i get
      1. Too many positional arguments: 1 allowed but 2 found
      2.uri error of some different type

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

      Thanks a lot

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

      Thanks bro

  • @MrDuda
    @MrDuda 4 года назад +169

    For those who want to experiment another time zone which has offset in minutes too, don't forget to add that too:
    String offset1 = data['utc_offset'].substring(1,3);
    String offset2 = data['utc_offset'].substring(4,6);
    DateTime now = DateTime.parse(datetime);
    now = now.add(Duration(hours: int.parse(offset1), minutes: int.parse(offset2)));
    print(now);

    • @astronautpolar596
      @astronautpolar596 4 года назад +2

      thanks

    • @nitinkaushik5144
      @nitinkaushik5144 4 года назад +13

      or instead of declaring two Strings 'offset1' & 'offset2' we could simply add minutes to our DateTime object to whatever timezone minutes you want to add.
      for example: now = now.add(Duration(hours: int.parse(offset), minutes: 30));

    • @shishirkumarsky
      @shishirkumarsky 4 года назад +2

      Thank you 🥺🥺

    • @barath4829
      @barath4829 4 года назад +2

      @@nitinkaushik5144 @Mr Duda thanks a lot🥺🥺

    • @kaustubhxdd
      @kaustubhxdd 4 года назад +6

      He actually kind of forgets there are offsets like -01:30, denoting negative offset having hours as 1 and minutes as 30.
      A quick fix to this, although I'm sure there are better methods around, is:
      String datetime = time['datetime'];
      List offset =
      time['utc_offset'].split(':').map((e) => int.parse(e)).toList();
      DateTime now = DateTime.parse(datetime);
      now = now.add(Duration(hours: offset[0], minutes: offset[1]));

  • @romualdomariano1457
    @romualdomariano1457 3 года назад +32

    You don't need the offset anymore. The API ensures the date and time is correct at specific region. Just use the 'datetime' property and you're good to go. But if you want to use the datetime that has no offset, you can use the 'utc_datetime' property.

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

      Thanks so much man

    • @Dogflamingo
      @Dogflamingo Год назад +3

      'datetime' still has an offset, which means when converting it to a DateTime object the time still ends up being off
      So, what I did was:
      "
      String datetime = data["datetime"];
      datetime = datetime.substring(0, datetime.length - 6);
      "

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

      ​@@Dogflamingo The reason that might be happening might be, the console prints the date in UTC time zone. In the video, even though the time looks correct i.e. "5:54" in London, in reality that is "5:54" in UTC which incorrect time.

    • @emmanuelmtegha3361
      @emmanuelmtegha3361 2 месяца назад +1

      @@Dogflamingo Thank you for this, i was struggling here

  • @sundaya.philips695
    @sundaya.philips695 4 года назад +3

    You are just amazing. I never knew i will learn flutter with ease. I stopped last year as it was quite confusing, just three days i came across this videos i can code effortlessly. Many thanks bro for the good job. You are a talented and amazing code coach.

  • @troydontigney7851
    @troydontigney7851 4 года назад +51

    This is made unnecessarily difficult by the way the DateTime.parse() function works. The 'datetime' property actually contains the exact time you want, but includes the offset at the end. DateTime.parse() automatically adds the offset, resulting in a DateTime object that is always set to UTC. An alternate method is to just make a substring of the first 26 characters (i.e. remove the offset from the 'datetime' property) and then parse that string like so:
    String datetime = data['datetime'];
    DateTime now = DateTime.parse(datetime.substring(0,26));

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

      Thanks So much!!

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

      thx

    • @chiraglunagaria4597
      @chiraglunagaria4597 3 года назад +2

      can anyone share whole code. I am stuck as time zone link is not working and showing long error in debug console.

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

      This is the only method that worked for me....thnx so much

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

      I've noticed that too and was wondering why he just didn't use datetime from JSON, but here's the answer.

  • @fruitfcker5351
    @fruitfcker5351 3 года назад +8

    07:57 This is incorrect. You have to include the sign at position 0. Otherwise for Timezones with negative (-) like Los Angeles (-08:00) it will add to the current time and the time will be incorrect. Still a great series and I love it.

  • @arisraymis6612
    @arisraymis6612 4 года назад +6

    There is some time zones that have a negative offset number, so the correct thing to do is to set substring(0, 3) otherwise it will only add the offset.

  • @vinayindoria
    @vinayindoria 4 года назад +1

    You have a very unique style of putting forward things. Recently stumbled upon your channel for some react concepts but ended up looking for other topics as well. Thanks for the videos..
    2 things,
    1. The response from the API your referring to already has utc_datetime and datetime variable so if we had to go forward with the offset addition and subtraction method then one should use utc_datetime response variable(This is obviously for other viewers)
    2. I guess offsets can be in negative as well so again for other viewers one should take into consideration the addition and subtraction symbol before the offset amount. Or rather use a library which will help you increase or decrease the datetime with relevant timezone offsets.
    Once again thanks for such informative videos.

  • @jaigarg3990
    @jaigarg3990 4 года назад +6

    Thanks for the tutorials mate.
    I was planning on building an app for my business for a long time, but now I can definitely do it

  • @rankddum5219
    @rankddum5219 2 года назад +10

    Now there is an easier way to add the offset, simply by just running:
    `DateTime date = DateTime.parse(data["datetime"]).toLocal();`
    it will automatically add the offset to the date
    (add .toLocal() method to the DateTime object)

  • @khondwanimtonga9703
    @khondwanimtonga9703 4 года назад +1

    Cheer brother! You've helped immensely! I got a new job that required an app developed by using flutter and I was lost up until these tutorials. Bless your talented heart! You're amazing at what you do I swear.
    Subscribed, liked, hit the bell icon. Most definitely recommend this channel to other devs.

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

    The time you calculated was not in London but UTC (you get time in london and add offset to it). Anyway your videos helps me a lot :)

  • @Ancientfall
    @Ancientfall 4 года назад +12

    I'm in a timezone with a negative offset (-03:00) and you need to have the sign in front of the offset otherwise is always a positive number. The + or - in the front dosen't seems to bother the int convertion.
    String offset = data['utc_offset'].substring(0, 3);

    • @muhammedp903
      @muhammedp903 4 года назад

      I found this out too when the time was wrong for some timezones.

    • @optimusx51
      @optimusx51 4 года назад

      This is what was messing me up, good call.

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

      You can add
      int sign = offset.substring(0, 1) == "+" ? 1 : -1;
      and then modify the now variable to be
      now = now.add(Duration(hours: int.parse(offset.substring(1, 3) * sign)));

    • @jonnieZG
      @jonnieZG 2 месяца назад

      @@aghiadalzein3069 no need for that, int.parse does read the sign, so just substring(0, 3) will work

  • @MuhammadRizwan-gm7vb
    @MuhammadRizwan-gm7vb 4 года назад +13

    i will not forget you in my prayers

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

    For anyone having issues with `Unhandled Exception: FormatException: Unexpected character (at character 1)`
    What's likely failing is when we're trying to decode the body since we're assuming the body is a json format.
    The issue is when we retrieve the response and there was an error from the server, the body will be an html format instead and confuse the json decoder.
    So we can check the response's status code first, and only proceed if it's 200, otherwise it's an error and we can print it out.
    For my case sometimes I did get 200 and everything worked ok, but other times the response was returning 503 (Service Unavailable).
    This is not really our fault, just an issue on the server's side.
    So you can check if it's a bad response then throw or print the error:
    if (response.statusCode != 200) {
    throw("Bad response ${response.statusCode}: ${response.body}");
    }

    • @성이름-i2k8s
      @성이름-i2k8s 2 года назад

      I've also had trouble with this error, but I got fix about it.
      The Troubleshooter of my problem is that check the get() function.
      By this time(2021.12.13), it's syntax is little different from the video's.
      you should use get(Uri.http('first argument' , 'second argument' ) instead of using get('full length of the site's location.)
      and the first argument is constitued only by the small alphabet and dot(.) which means it doesnt allow to be putted the slash(/).
      And the rest of the site's location will be placed at the second argument, also containing variable which is developer privatly make.(And also dont forget about the $ before the variable.)

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

    You are the real teacher ❤️❤️❤️❤️❤️❤️❤️❤️, lots of good wishes for you sir

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

    If you want UTC negative offsets get the whole string included inthe + - signs when parsing offset
    String datetime = data['datetime'];
    int offset = int.parse(data['utc_offset'].substring(0, 3));
    DateTime now = DateTime.parse(datetime);
    now = now.add(Duration(hours: offset));
    print(now);
    }

  • @MuhammadRizwan-gm7vb
    @MuhammadRizwan-gm7vb 4 года назад +2

    wow....that's amazing, in android java, i need to write a big code to get response from server, boy I am in love with flutter, love you sir

  • @hariharasudansavithrianbar9703
    @hariharasudansavithrianbar9703 4 года назад

    You are way better than those paid courses man!

  • @dayson2489
    @dayson2489 4 года назад

    For those who live in the North America or with a negative offset ..
    String symbol = data['utc_offset'].toString().substring(0,1);
    DateTime now = DateTime.parse(datetime);
    now = symbol == '-' ? now.subtract(Duration(hours: int.parse(offset))) : now.add(Duration(hours: int.parse(offset))) ;
    which is the same as ...
    if (symbol == '-') {
    now = now.subtract(Duration(hours: int.parse(offset)));
    } else {
    now = now.add(Duration(hours: int.parse(offset)));
    }

  • @uranberisha9864
    @uranberisha9864 5 лет назад +14

    in 24 row code must be:
    String offset = data['utc_offset'].substring(0,3);
    For negative utc_offset e. g. America/Chicago = '-06:00' if you substring(0,2) you get +6

    • @topbun1226
      @topbun1226 4 года назад +3

      Also in Western Hemisphere here, this is the right way to fix it!

    • @arifulislamkhokon5432
      @arifulislamkhokon5432 4 года назад

      or make a function like that
      DateTime dateGenerate(String utcTime,String utcOffset){
      var hourWithSign=num.parse(utcOffset.split('.')[0]);
      var minutesWithSign=num.parse(utcOffset.substring(0,1)+utcOffset.split('.')[1]);
      DateTime now=DateTime.parse(utcTime);
      now =now.add(Duration(hours: hourWithSign));
      now =now.add(Duration(minutes:minutesWithSign));
      print(now);
      }

    • @morphx666
      @morphx666 4 года назад

      I ended up using offset.split(":")[0] instead.

    • @zakirfaizal6321
      @zakirfaizal6321 4 года назад

      Thank you sir!

    • @tharwatelsayed7600
      @tharwatelsayed7600 4 года назад

      i think in your case it should be
      now= now.subtract(Duration(hours: int.parse(offset)));

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

    For those who cant get response from the run panel try to do "Hot Restart" instead of "CTRL + S".

  • @letsgodevs
    @letsgodevs 4 года назад

    this is the best channel for me .. thank you mate

  • @jlatham203
    @jlatham203 3 года назад +23

    I have found out that there may be an error when running the program with the end link, from World Time API, starting with 'http'. Rather it should start with 'https'. I had this error and could not figure out what was the issue until I came across this info.

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

      I had the same problem, did u find the solution already?

    • @jlatham203
      @jlatham203 3 года назад +2

      @@levisatto8268 Yes, I found some information from StackOverflow. You can change the starting point of the world time API link to 'https' instead of using 'http'. I'm not sure if your network area has any effect on this option.

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

      @@jlatham203 it worked, thank u!

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

      thankyou brother you solved my error

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

      Thank you it worked for me

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

    For those of you that are getting an error from the api. As of Android API 28 and iOS 9, http is not allowed anymore. You will need to add `` to your "AndroidManifest.xml" (android/app/src/debug/AndroidManifest.xml) file inside the tags. I got it working so if you have any more questions feel free to ask and I'll try to help!

    • @Abhi-ng3re
      @Abhi-ng3re 3 года назад

      i did this.. but its still not working. could you help me with it please ?

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

      @@Abhi-ng3re mind linking your gh so I can look at it. I should have the project on my gh `tbaustin` if you want to just copy my file.

  • @docdsmc6639
    @docdsmc6639 5 лет назад +1

    Great video series. I'd love to see you cover application state management in some detail and SQL Lite usage, storing prefs in a file or via the stored_preferences package.

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

    Very nice tutorial, it's been an absolute blast so far. On the World App thingy, I think the datetime only shows the time in our current location irrespective of the utc while the Utc_datetime shows the region we're using. My utc_offset is +01:00( which also is my country's timezone) while the datetime shows my local time. I think instead of adding the utc_offset after converting to DateTime object, i need to substract my timezone (utc_offset) from it to get London accurate time

  • @zachyang1041
    @zachyang1041 4 года назад

    You could also do:
    String dataTime = data["utc_datetime"];
    String offset = data["utc_offset"].substring(0, 3);
    DateTime now = DateTime.parse(dataTime).add(Duration(hours: int.parse(offset)));
    So that if the offset is negative, it converts the offset to a negative value.

  • @ikarosouza4680
    @ikarosouza4680 4 года назад +7

    Isn't the datetime property already with the offset? The "+1:00" is right there at the end of the string

  • @joegoodman4358
    @joegoodman4358 4 года назад

    I was having a problem with some timezones, the london one was correct, but others like the México timezone were wrong. I made some research and had to change this:
    String offset = data['offset'].substring(1, 3);
    For this:
    String offset = data['utc_offset'].substring(0, 3);
    Hope this helps someone :)

  • @marcellerich
    @marcellerich 5 лет назад +6

    First, I love your videos (and accent), great work. Thank you very much!
    And then just a thought: what happens if the offset is negative?

    • @FattigHjonen
      @FattigHjonen 4 года назад +4

      Won't work. Same goes for countries with plus half hours.
      Fast simple solution:
      String offsetHours = offset.substring(0,1) + offset.substring(2,3);
      String offsetMin = offset.substring(0,1) + offset.substring(4,6);
      DateTime now = DateTime.parse(datetime);
      now = now.add(Duration(hours: int.parse(offsetHours), minutes: int.parse(offsetMin)));
      Otherwise thank you for some great tutorials Ninja!!

    • @sebastiansalinas7494
      @sebastiansalinas7494 4 года назад

      @@FattigHjonen thanks for that!! really helpful

    • @ranjanpanda2586
      @ranjanpanda2586 4 года назад

      @@FattigHjonen thanks a ton

  • @hardiklakhalani6268
    @hardiklakhalani6268 3 года назад +5

    // You forgot main thing here or maybe you skipped for us to learn which is Adding Minutes & Subtracting if it is Negative TimeZone like -08:30 or +05:30. I've done it by trial n error. LEARNED it though. Thanks
    //Creating DateTime Object
    DateTime now = DateTime.parse(datetime); //convert to readable D & T
    String sign = fetchedData['utc_offset'][0]; // Knowing TimeZone + or -
    // Time Add or Minus based on TimeZone + or -
    if (sign == '+') {
    now = now.add(Duration(
    hours: int.parse(offsetHours), minutes: int.parse(offsetMins)));
    } else {
    now = now.subtract(Duration(
    hours: int.parse(offsetHours), minutes: int.parse(offsetMins)));
    }
    print(now);

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

      String offsetHours = data['utc_offset'].substring(1, 3);
      String offsetMins = data['utc_offset'].substring(4, 6);

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

    If you get "[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Bad state: Insecure HTTP is not allowed by platform:"
    Just change "http" by "https".

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

      Thanks.
      This works for me

    • @olala-j7g
      @olala-j7g 3 года назад

      you are freaking magician

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

      Thank you, it works fine now

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

      thanks, now my code running i am not any any output from print statement. can you help me, i am facing the same problem from the last video onward.

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

      thanks, it worked

  • @dkapur17
    @dkapur17 4 года назад

    Just a heads up. I think there is a mistake around the 7:30 mark when he says we don't need the '+' symbol. That's alright for all the locations with positive offset because no sign is the same as +ve sign. However, for locations to the west of the Prime Meridian, namely the Americas and a bit of Europe and Africa, the offset is -ve and skipping the sign would actually yield a wrong final time. Fix is straightforward, just change
    String offset = data['utc_offset'].substring(1, 3)
    to
    String offset = data['utc_offset'].substring(0, 3)

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

    I believe you don't really need the offset since the data['datetime'] already has an offset at the end: e.g. 2021-03-05T05:33:46.858695+00:00 (offset). Correct me if i'm wrong, cuz I don't work with dates that often.

  • @bahaaodeh5658
    @bahaaodeh5658 4 года назад

    I think that the response includes 2 times
    datetime: which is user timezone calculated
    utc_datetime: is the UTC timezone
    so if we need to use DateTime object to format the time we should use utc_datetime + utc_offset
    but the point is that DateTime.parse is ignoring the timezone so the result is the same

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

    Thank You Sir for the guidance
    Stay Blessed

  • @Asquare17
    @Asquare17 4 года назад

    Thanks brother for the tutorial. You made flutter easy for me.
    However, i felt our offset substring should be subString(0,3) not subString(1,3) to cater for negative offset timezones.

  • @eldarkk4566
    @eldarkk4566 4 года назад

    Bro, Z char in the end of date object means UTC time zone =(. If u print your date regarding to your time zone, u will get proper date time. But u hardly added 1 hour, so u will get date time in +2 timezone. Anyway u r awesome dude.

  • @tjkn8734
    @tjkn8734 4 года назад

    07:45 I think we should use "String offset = data['utc_offset'].substring(0, 3);" to account for "plus" or "minus" in front of the utc_offset data.

  • @rutviktak716
    @rutviktak716 4 года назад

    Best tutorials on flutter😍😃

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

    Removing + sign from offset prevent you of getting negative offsets which results wrong time for those locations. We need to get plus and minus signs if we want to get time based on GMT for instance (as result of this API provider is always down, returning 503 error)

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

      It does not prevent from getting the offset it just doesn't show it on screen

  • @juaninfante7000
    @juaninfante7000 Год назад +3

    At time 1:15, you share your Ip address. I don't know if you care about it, but I recommend blurring it out if you don't mind having the type of information out there.

  • @jeremiaholuwaseun7327
    @jeremiaholuwaseun7327 4 года назад +2

    pls i get this error whenever i tried hot reload "E/flutter ( 4312): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FormatException: Unexpected character (at character 1)
    E/flutter ( 4312):

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

    If y'all think offset method is confusing just do:
    String datetime = data['datetime'];
    DateTime now = DateTime.parse(datetime.substring(0, 26));
    print(now);

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

    Just to clarify that the worldtimeapi works just fine at the time im writing this. Cheers.

  • @h0pp3rt
    @h0pp3rt 3 месяца назад

    The "datetime" value already contains the "utc_offset" but the parser ignores it. Switch to "utc_datetime" as it makes no difference and avoids confusion.

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

    Timezones
    Below is a list of recognised timezones. This list is also available via the API. Check the spec for more details.
    Africa/Abidjan
    Africa/Accra
    Africa/Algiers
    Africa/Bissau
    Africa/Cairo
    Africa/Casablanca
    Africa/Ceuta
    Africa/El_Aaiun
    Africa/Johannesburg
    Africa/Juba
    Africa/Khartoum
    Africa/Lagos
    Africa/Maputo
    Africa/Monrovia
    Africa/Nairobi
    Africa/Ndjamena
    Africa/Sao_Tome
    Africa/Tripoli
    Africa/Tunis
    Africa/Windhoek
    America/Adak
    America/Anchorage
    America/Araguaina
    America/Argentina/Buenos_Aires
    America/Argentina/Catamarca
    America/Argentina/Cordoba
    America/Argentina/Jujuy
    America/Argentina/La_Rioja
    America/Argentina/Mendoza
    America/Argentina/Rio_Gallegos
    America/Argentina/Salta
    America/Argentina/San_Juan
    America/Argentina/San_Luis
    America/Argentina/Tucuman
    America/Argentina/Ushuaia
    America/Asuncion
    America/Atikokan
    America/Bahia
    America/Bahia_Banderas
    America/Barbados
    America/Belem
    America/Belize
    America/Blanc-Sablon
    America/Boa_Vista
    America/Bogota
    America/Boise
    America/Cambridge_Bay
    America/Campo_Grande
    America/Cancun
    America/Caracas
    America/Cayenne
    America/Chicago
    America/Chihuahua
    America/Costa_Rica
    America/Creston
    America/Cuiaba
    America/Curacao
    America/Danmarkshavn
    America/Dawson
    America/Dawson_Creek
    America/Denver
    America/Detroit
    America/Edmonton
    America/Eirunepe
    America/El_Salvador
    America/Fort_Nelson
    America/Fortaleza
    America/Glace_Bay
    America/Goose_Bay
    America/Grand_Turk
    America/Guatemala
    America/Guayaquil
    America/Guyana
    America/Halifax
    America/Havana
    America/Hermosillo
    America/Indiana/Indianapolis
    America/Indiana/Knox
    America/Indiana/Marengo
    America/Indiana/Petersburg
    America/Indiana/Tell_City
    America/Indiana/Vevay
    America/Indiana/Vincennes
    America/Indiana/Winamac
    America/Inuvik
    America/Iqaluit
    America/Jamaica
    America/Juneau
    America/Kentucky/Louisville
    America/Kentucky/Monticello
    America/La_Paz
    America/Lima
    America/Los_Angeles
    America/Maceio
    America/Managua
    America/Manaus
    America/Martinique
    America/Matamoros
    America/Mazatlan
    America/Menominee
    America/Merida
    America/Metlakatla
    America/Mexico_City
    America/Miquelon
    America/Moncton
    America/Monterrey
    America/Montevideo
    America/Nassau
    America/New_York
    America/Nipigon
    America/Nome
    America/Noronha
    America/North_Dakota/Beulah
    America/North_Dakota/Center
    America/North_Dakota/New_Salem
    America/Nuuk
    America/Ojinaga
    America/Panama
    America/Pangnirtung
    America/Paramaribo
    America/Phoenix
    America/Port-au-Prince
    America/Port_of_Spain
    America/Porto_Velho
    America/Puerto_Rico
    America/Punta_Arenas
    America/Rainy_River
    America/Rankin_Inlet
    America/Recife
    America/Regina
    America/Resolute
    America/Rio_Branco
    America/Santarem
    America/Santiago
    America/Santo_Domingo
    America/Sao_Paulo
    America/Scoresbysund
    America/Sitka
    America/St_Johns
    America/Swift_Current
    America/Tegucigalpa
    America/Thule
    America/Thunder_Bay
    America/Tijuana
    America/Toronto
    America/Vancouver
    America/Whitehorse
    America/Winnipeg
    America/Yakutat
    America/Yellowknife
    Antarctica/Casey
    Antarctica/Davis
    Antarctica/DumontDUrville
    Antarctica/Macquarie
    Antarctica/Mawson
    Antarctica/Palmer
    Antarctica/Rothera
    Antarctica/Syowa
    Antarctica/Troll
    Antarctica/Vostok
    Asia/Almaty
    Asia/Amman
    Asia/Anadyr
    Asia/Aqtau
    Asia/Aqtobe
    Asia/Ashgabat
    Asia/Atyrau
    Asia/Baghdad
    Asia/Baku
    Asia/Bangkok
    Asia/Barnaul
    Asia/Beirut
    Asia/Bishkek
    Asia/Brunei
    Asia/Chita
    Asia/Choibalsan
    Asia/Colombo
    Asia/Damascus
    Asia/Dhaka
    Asia/Dili
    Asia/Dubai
    Asia/Dushanbe
    Asia/Famagusta
    Asia/Gaza
    Asia/Hebron
    Asia/Ho_Chi_Minh
    Asia/Hong_Kong
    Asia/Hovd
    Asia/Irkutsk
    Asia/Jakarta
    Asia/Jayapura
    Asia/Jerusalem
    Asia/Kabul
    Asia/Kamchatka
    Asia/Karachi
    Asia/Kathmandu
    Asia/Khandyga
    Asia/Kolkata
    Asia/Krasnoyarsk
    Asia/Kuala_Lumpur
    Asia/Kuching
    Asia/Macau
    Asia/Magadan
    Asia/Makassar
    Asia/Manila
    Asia/Nicosia
    Asia/Novokuznetsk
    Asia/Novosibirsk
    Asia/Omsk
    Asia/Oral
    Asia/Pontianak
    Asia/Pyongyang
    Asia/Qatar
    Asia/Qostanay
    Asia/Qyzylorda
    Asia/Riyadh
    Asia/Sakhalin
    Asia/Samarkand
    Asia/Seoul
    Asia/Shanghai
    Asia/Singapore
    Asia/Srednekolymsk
    Asia/Taipei
    Asia/Tashkent
    Asia/Tbilisi
    Asia/Tehran
    Asia/Thimphu
    Asia/Tokyo
    Asia/Tomsk
    Asia/Ulaanbaatar
    Asia/Urumqi
    Asia/Ust-Nera
    Asia/Vladivostok
    Asia/Yakutsk
    Asia/Yangon
    Asia/Yekaterinburg
    Asia/Yerevan
    Atlantic/Azores
    Atlantic/Bermuda
    Atlantic/Canary
    Atlantic/Cape_Verde
    Atlantic/Faroe
    Atlantic/Madeira
    Atlantic/Reykjavik
    Atlantic/South_Georgia
    Atlantic/Stanley
    Australia/Adelaide
    Australia/Brisbane
    Australia/Broken_Hill
    Australia/Darwin
    Australia/Eucla
    Australia/Hobart
    Australia/Lindeman
    Australia/Lord_Howe
    Australia/Melbourne
    Australia/Perth
    Australia/Sydney
    CET
    CST6CDT
    EET
    EST
    EST5EDT
    Etc/GMT
    Etc/GMT+1
    Etc/GMT+10
    Etc/GMT+11
    Etc/GMT+12
    Etc/GMT+2
    Etc/GMT+3
    Etc/GMT+4
    Etc/GMT+5
    Etc/GMT+6
    Etc/GMT+7
    Etc/GMT+8
    Etc/GMT+9
    Etc/GMT-1
    Etc/GMT-10
    Etc/GMT-11
    Etc/GMT-12
    Etc/GMT-13
    Etc/GMT-14
    Etc/GMT-2
    Etc/GMT-3
    Etc/GMT-4
    Etc/GMT-5
    Etc/GMT-6
    Etc/GMT-7
    Etc/GMT-8
    Etc/GMT-9
    Etc/UTC
    Europe/Amsterdam
    Europe/Andorra
    Europe/Astrakhan
    Europe/Athens
    Europe/Belgrade
    Europe/Berlin
    Europe/Brussels
    Europe/Bucharest
    Europe/Budapest
    Europe/Chisinau
    Europe/Copenhagen
    Europe/Dublin
    Europe/Gibraltar
    Europe/Helsinki
    Europe/Istanbul
    Europe/Kaliningrad
    Europe/Kiev
    Europe/Kirov
    Europe/Lisbon
    Europe/London
    Europe/Luxembourg
    Europe/Madrid
    Europe/Malta
    Europe/Minsk
    Europe/Monaco
    Europe/Moscow
    Europe/Oslo
    Europe/Paris
    Europe/Prague
    Europe/Riga
    Europe/Rome
    Europe/Samara
    Europe/Saratov
    Europe/Simferopol
    Europe/Sofia
    Europe/Stockholm
    Europe/Tallinn
    Europe/Tirane
    Europe/Ulyanovsk
    Europe/Uzhgorod
    Europe/Vienna
    Europe/Vilnius
    Europe/Volgograd
    Europe/Warsaw
    Europe/Zaporozhye
    Europe/Zurich
    HST
    Indian/Chagos
    Indian/Christmas
    Indian/Cocos
    Indian/Kerguelen
    Indian/Mahe
    Indian/Maldives
    Indian/Mauritius
    Indian/Reunion
    MET
    MST
    MST7MDT
    PST8PDT
    Pacific/Apia
    Pacific/Auckland
    Pacific/Bougainville
    Pacific/Chatham
    Pacific/Chuuk
    Pacific/Easter
    Pacific/Efate
    Pacific/Enderbury
    Pacific/Fakaofo
    Pacific/Fiji
    Pacific/Funafuti
    Pacific/Galapagos
    Pacific/Gambier
    Pacific/Guadalcanal
    Pacific/Guam
    Pacific/Honolulu
    Pacific/Kiritimati
    Pacific/Kosrae
    Pacific/Kwajalein
    Pacific/Majuro
    Pacific/Marquesas
    Pacific/Nauru
    Pacific/Niue
    Pacific/Norfolk
    Pacific/Noumea
    Pacific/Pago_Pago
    Pacific/Palau
    Pacific/Pitcairn
    Pacific/Pohnpei
    Pacific/Port_Moresby
    Pacific/Rarotonga
    Pacific/Tahiti
    Pacific/Tarawa
    Pacific/Tongatapu
    Pacific/Wake
    Pacific/Wallis

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

    I think offset should be also substring 1st character to deal with the negative timezone offset
    String offset = data['utc_offset'].substring(0, 3);

  • @andreranulfo-dev8607
    @andreranulfo-dev8607 4 года назад

    Flutter is life.

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

    You don't need to add the offset as the API gives the datetime with the offset pre added

  • @nassimmehalli7043
    @nassimmehalli7043 5 лет назад +16

    i don't understand why you are using add method to have the datetime in London when this date time is the value of the key "utc datetime"?

    • @adamcierniak3902
      @adamcierniak3902 4 года назад +1

      To show posibility. Not everyone live in London

    • @MrAntarpreets
      @MrAntarpreets 4 года назад +8

      @@adamcierniak3902 Since the api already returned time in the requested timezone, he'd have been better off directly printing it here. Since he later uses intl library, he could've used DateFormat.parse to get the user friendly version.
      However, if the intent was to demo dart's DateTime - he should've used utc_datetime from the JSON response along with utc_offset for clarity. Also, since there are negative and positive time zone offsets and not all are aligned to an hour either - the parsing to add was insufficient. A note to the user there about the deficiency should've been there. DateTime is hard in general.

    • @hassan_codes
      @hassan_codes 4 года назад

      It's not UTC all year round because of daylight saving

    • @carswithmula
      @carswithmula 4 года назад +4

      I believe he was supposed to use the 'utc_datetime' not the 'datetime', then add the offset to it.

  • @advaitchabukswar4163
    @advaitchabukswar4163 Год назад +1

    The offset should be String offset = data['utc_offset'].substring(0,3); rather than (1,3) to account for timezones that have a negative offset.

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

      Gracias, me funcionó de la manera que mencionas; Estoy usando una zona horaria que tiene ""utc_offset": "-03:00""

  • @DanaKurdi
    @DanaKurdi 4 года назад +2

    Thank You !

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

    Thank you so much for your effort

  • @shubhamgupta-to7so
    @shubhamgupta-to7so 5 лет назад +1

    Hi Shaun,
    Please update the video title, its #27 video, and title says #7
    and thanks again for such an awesome content

    • @NetNinja
      @NetNinja  5 лет назад +2

      Thanks, sorted :)

  • @carlosandressanchez5211
    @carlosandressanchez5211 4 года назад

    4:07
    Fascinating advise, actually

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

    just amazing explaination....

  • @WDIDMASTER
    @WDIDMASTER 4 года назад +1

    Any fix on how to fix this error E/flutter ( 6393): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: OS Error: Connection timed out, errno = 110, address = jsonplaceholder.cypress.io, port = 42245
    I get it after I try to access the JSON placeholder text. 10 percent of the time it works but then after I reset the error pops back up again

  • @ProgrammingwithPeter
    @ProgrammingwithPeter 5 лет назад

    Flutter evolved so much, I think if the they will make a stable version for the web part, it will become a standard.

    • @vigneshs2886
      @vigneshs2886 5 лет назад +1

      Also waiting for Flutter for PC, Mac & Linux

    • @ProgrammingwithPeter
      @ProgrammingwithPeter 5 лет назад

      @@vigneshs2886 yep, but if it will be for Web, we can wrap it into electron

  • @johnathanvargas5594
    @johnathanvargas5594 4 года назад

    i don't if this is the best practice for programming or not cause i'm still new to programming in general. but for negative offset i got this to work for me.
    // create DateTime object
    DateTime now = DateTime.parse(datetime);
    print(data['utc_offset'].substring(0,1));
    data['utc_offset'].substring(0,1) == '+' ? now = now.add(Duration(hours:int.parse(offset))) :now = now.subtract(Duration(hours:int.parse(offset)));

    • @tanmayhinge
      @tanmayhinge 4 года назад

      i dont think you really need to use that ternary operation cause we are already using a substring...instead you may use now.subtract()

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

    bro the world time api link is not in the description box

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

    Amaaazing maaaan thank you sooo much

  • @fase-man6355
    @fase-man6355 3 года назад

    This is awesome

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

    I know i'm probably just one more random comment here, but I, such as hundreds of people that were following the incredible tutorial that this has been, have not been able to proceed with it. as we're getting errors related to the API. I, myself, was not able to do anything past 4:10.
    We would reaaly apreciate ur help, Sir, if possible.

  • @narharos4974
    @narharos4974 5 лет назад +1

    I think it's better to use Current Local Date directly.

    • @JudWhite1
      @JudWhite1 5 лет назад

      Dart DateTime objects don't carry timezone information, toLocal() always returns the date/time converted to the environment's local time. It'll use the UTC offset in the string when parsing to create a DateTime object where isUtc = true, i.e. it adds/subtracts the offset to the time then discards that information. api.dartlang.org/stable/2.6.0/dart-core/DateTime/parse.html. The "timezone" or "time_machine" packages might be helpful, or for this specific case, you could just chop off the offset before parsing to get the intended date/time representation.

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

    its an incredible one there, but i can't find the link to the world time api site in the description box

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

    Can you please explain me the point on why you add now twice to get the updated time?

  • @mikolajhenzel
    @mikolajhenzel 4 года назад

    Will you Master make a tutorial about executing tests in Flutter?

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

    thank you

  • @AntStudioschannel
    @AntStudioschannel 4 года назад +1

    E/flutter (29833): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: Failed host lookup: 'worldtimeapi.org' (OS Error: No address associated with hostname, errno = 7)
    E/flutter (29833):
    I'm facing this error I'm not understanding what it is can anyone let me know please

    • @mahammad4051
      @mahammad4051 4 года назад

      you have to have active internet connection on your phone/emulator

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

    Hartley thanks....@The Net Ninja

  • @hamada010
    @hamada010 4 года назад +1

    The request takes more than 1.5 minutes to show a response , am using an Android studio emulator, followed your guide step by step. any idea?

  • @AwankemBenjamin-y3u
    @AwankemBenjamin-y3u 9 месяцев назад +2

    please for the link to the api

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

    @8:52 we make a request and API gives us time as 16:53:48
    @9:21 we fix the mistake and API gives us time as 17:54:42
    in video time, it is 29 seconds, in real time it is 54 seconds :d
    either api is broken or a seamless edit :d

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

    Hey, after parse the date always show me utc date, but not from this place. i have everything the same, what can go wrong?

  • @f3-faithfitnessfinance
    @f3-faithfitnessfinance 5 лет назад

    Bro, do a video on date and time picker🙏

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

    Am following all your tutorials and its amazingly great...🔥🔥,You are a great teacher.....
    But it hurts when the worldtime api doesn't work anymore....
    Any alternatives?🥺

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

      Bruh, Ive been strugling for 2 hours, but i finally found another site with world time. If you want you could try, lemme know then.
      app.abstractapi.com/

    • @rcexpfpv481
      @rcexpfpv481 3 года назад +3

      You can still use it, just type the host in with "https" instead of "http" so esentially: worldtimeapi.org/api/timezone/...

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

      @@rcexpfpv481 Thank you for this!

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

      @@rcexpfpv481 Thanks. Was stuck on this one for a while

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

    There is this one mistake, that i found out, if we do not consider the + and - sign of utc-offset then it will always be + as we are adding the offset which will always give wrong answers to -ve utc timezones. You can google the current time like chichago current time and compare it with your result. There will be difference in it.

  • @raphalugs
    @raphalugs 5 лет назад +2

    And what should I do when the utc_offset is negative? I've just changed the .substring(1,3) to .substring(0,3) but I want to know if it has another way. Thanks for the videos ♥

    • @RagePeanut
      @RagePeanut 5 лет назад +2

      Check if the first character of the offset is a '+' or a '-' with an if statement. If it's a '+', call the add method, else call the subtract method.

    • @ChadVick
      @ChadVick 5 лет назад +2

      I did not see a "subtract" method in the Dart docs. In my conditional statement I inserted "-" before "int.parse(offset)", and it worked. However, I think Raphael's approach of using a wider substring is much cleaner. Thanks for the insight!

    • @phuocantd
      @phuocantd 4 года назад

      I used String offset = data['utc_offset'].substring(0, 3); and it worked

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

    One problem that I am discovering is that , we are only changing the offset hours ,and not the minutes.

  • @mahersalamin623
    @mahersalamin623 4 года назад

    I appreciate your work and labor, but i have a problem with the data from this api or the api from the last video. no data came to the screen, only lines of did i touched the screen or not....

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

    Now start game development, and teaching us🙏🤗🤗🤗

  • @rationalhat9811
    @rationalhat9811 3 года назад +2

    my time zone is +5:30 , so how do i add that to datetime?, i'm getting an error when adding 5:30 but there is no error when adding just 05.

  • @JuanLopez-oc9yv
    @JuanLopez-oc9yv 4 года назад +1

    The course haS been great but I am getting this error when requesting the API:
    Exception has occurred.
    ClientException (Connection closed before full header was received)

  • @The0nlySplash
    @The0nlySplash 4 года назад +1

    The worldtimeapi is down currently. What a bummer

  • @hammadulaziz1064
    @hammadulaziz1064 4 года назад

    great💜💙

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

    This tutorial series was great, but I think we need an updated version of this. I am incredible confused now that the API website is completely different.

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

      Me too, please can you point me to where I can fine a free world time API, I've scoured the internet and I couldn't find any

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

      @@billikpe2718 Did you figure it out man?

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

      @@jamescoughlin6357 nope, I put a pause on that project

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

      can still use the same, but I have another problem It will take some number of times to response, after I tried the third time only I recieved the response, but then when I hot reload again, it couldnt zzz....sometimes due to timeout and connection closed, so when u try to get the response when u request the worldtime api, it doesnt reach you and throws an error, I think just continue this tutorial playlist until exception handling

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

    ruclips.net/video/AqsmaT1U6sQ/видео.html offset is +01 but you removed + and only took 01 What if it is -04, 04 will be added to original time which is wrong, is it?

  • @chandrashekharkabanur6401
    @chandrashekharkabanur6401 5 лет назад +1

    What is the extension you use to view JSON data in your browser? Thanks for the great tutorial!

    • @beardjuice9959
      @beardjuice9959 4 года назад +1

      Not the exact same extension, but if you google "Chrome JSON Viewer" the first one that pops up is "JSON Viewer" and it's what I use. It has some pretty cool display configurations.

    • @roronoa_d_law1075
      @roronoa_d_law1075 4 года назад

      if you use mozilla firefox, you don't need extension :)

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

    Sir, The course project is out of date. Get error but I learn so many things.Thank you.

  • @DoctorCode9
    @DoctorCode9 4 года назад

    I really liked your video, they are very helpful, I want to ask if you use a son formatted extinction that allows you to display json in your browser like in the video ?

    • @ranjanpanda2586
      @ranjanpanda2586 4 года назад +1

      just use mozilla firefox

    • @DoctorCode9
      @DoctorCode9 4 года назад

      @@ranjanpanda2586 I used a google chrome extension, thank you

    • @ranjanpanda2586
      @ranjanpanda2586 4 года назад +1

      @@DoctorCode9 Saw your channel though. Loved it !!
      Do you make your source code public for the videos you make ??

    • @DoctorCode9
      @DoctorCode9 4 года назад +1

      @@ranjanpanda2586 Thank you for your feedback, yeah I share all my source code in my personal blog you will find it in my videos description and Soon I will release them into my github

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

    I get this error when I am using api, "Insecure HTTP is not allowed by platform" because its not a https endpoint. Is there an alternative?

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

      Bruh, Ive been strugling for 2 hours, but i finally found another site with world time. If you want you could try, lemme know then.
      app.abstractapi.com/

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

      @@mac3k282 Thanks man, I moved on doing other tutorials. Thank you though.

  • @James-nf4tm
    @James-nf4tm 2 года назад

    At 8:52 he say's the "now" object is "non-destructive." What does that mean? I'm from Java but I haven't come across that term yet in Java.

  • @kaustubhxdd
    @kaustubhxdd 4 года назад +1

    He actually kind of forgets there are offsets like -01:30, denoting negative offset having hours as 1 and minutes as 30.
    A quick fix to this, although I'm sure there are better methods around, is:
    String datetime = time['datetime'];
    List offset =
    time['utc_offset'].split(':').map((e) => int.parse(e)).toList();
    DateTime now = DateTime.parse(datetime);
    now = now.add(Duration(hours: offset[0], minutes: offset[1]));

    • @yashodeepdhas8408
      @yashodeepdhas8408 3 года назад +2

      Thanks Bro ... short and concise...this helped....Indian offset is +5:30

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

    why do we need to add the utc offset?....coz already the local time is given as datetime

  • @TheBitz23
    @TheBitz23 4 года назад

    Should I need a stable internet to do this?

  • @cryvage1354
    @cryvage1354 8 месяцев назад

    You can't just remove first symbol from the offset. Offset can be negative and then you need this minus. Moreover, why converting it to an integer if it's clearly of type Time.
    Also, what is "non destructive"? I though types like this are called "immutable."