Skip to content

Instantly share code, notes, and snippets.

@siteslave
Created March 25, 2021 06:05
Show Gist options
  • Save siteslave/2ef0d5c87430d8fe8c55aba8ab301e7f to your computer and use it in GitHub Desktop.
Save siteslave/2ef0d5c87430d8fe8c55aba8ab301e7f to your computer and use it in GitHub Desktop.
/*
main.dart
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('th', 'TH'),
],
*/
import 'package:intl/intl.dart';
class Helper {
Helper();
String toThaiDate(DateTime date) {
// create format
var strDate = new DateFormat.MMMd('th_TH').format(date);
var _strDate = '$strDate ${date.year + 543}';
// return thai date
return _strDate;
}
String toLongThaiDate(DateTime date) {
// create format
var strDate = new DateFormat.MMMMd('th_TH').format(date);
var _strDate = '$strDate ${date.year + 543}';
// return thai date
return _strDate;
}
String toLongThaiDateAndTime(DateTime date) {
// create format
var strDate = new DateFormat.MMMMd('th_TH').format(date);
var strTime = new DateFormat.Hm().format(date);
var _strDate = '$strDate ${date.year + 543} $strTime';
// return thai date
return _strDate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment